Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,26 @@ name: release
on:
push:
tags:
- 'v*'
- "v*"

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v6

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v6
with:
go-version: '1.23'
cache: false
go-version: "1.25.5"

- name: Create release notes
run: ./scripts/release.sh

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,29 @@ on:
pull_request:
branches: [main]
paths-ignore:
- '**.md'
- "**.md"
jobs:
test:
name: test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
go: ['1.23']
go: ["1.25.5"]

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v6

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v6
with:
go-version: '1.23'
cache: false
go-version: "1.25.5"

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v9
with:
version: v2.7.1

- name: Get dependencies
run: go get -v -t -d ./...
Expand Down
9 changes: 9 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: "2"

linters:
settings:
errcheck:
exclude-functions:
- fmt.Fprintf
- fmt.Fprint
- (io.Closer).Close
File renamed without changes.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ NAME := mani
PACKAGE := github.com/alajmo/$(NAME)
DATE := $(shell date +"%Y %B %d")
GIT := $(shell [ -d .git ] && git rev-parse --short HEAD)
VERSION := v0.31.1
VERSION := v0.31.2

default: build

Expand All @@ -19,7 +19,7 @@ gofmt:
go fmt ./test/integration/***.go

lint:
golangci-lint run ./cmd/... ./core/...
golangci-lint run ./...
deadcode .

test:
Expand Down
3 changes: 1 addition & 2 deletions core/dao/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ type Resource interface {
GetContextLine() int
}

// func (re *ResourceErrors[T]) Combine() error {
func FormatErrors(re Resource, errs []error) error {
var msg = ""
partsRe := regexp.MustCompile(`line (\d*): (.*)`)
Expand Down Expand Up @@ -97,7 +96,7 @@ func EvaluateEnv(envList []string) ([]string, error) {
return envs, nil
}

// Merges environment variables.
// MergeEnvs Merges environment variables.
// Priority is from highest to lowest (1st env takes precedence over the last entry).
func MergeEnvs(envs ...[]string) []string {
var mergedEnvs []string
Expand Down
20 changes: 10 additions & 10 deletions core/dao/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,15 +449,15 @@ func InitMani(args []string, initFlags core.InitFlags) ([]Project, error) {
return []Project{}, &core.AlreadyManiDirectory{Dir: configDir}
}

url, err := core.GetWdRemoteUrl(configDir)
url, err := core.GetWdRemoteURL(configDir)
if err != nil {
return []Project{}, err
}

rootName := filepath.Base(configDir)
rootPath := "."
rootUrl := url
rootProject := Project{Name: rootName, Path: rootPath, Url: rootUrl}
rootURL := url
rootProject := Project{Name: rootName, Path: rootPath, URL: rootURL}
projects := []Project{rootProject}
if initFlags.AutoDiscovery {
prs, err := FindVCSystems(configDir)
Expand Down Expand Up @@ -487,7 +487,7 @@ func InitMani(args []string, initFlags core.InitFlags) ([]Project, error) {

tmpl, err := template.New("init").Funcs(funcMap).Parse(`projects:
{{- range .}}
{{ (projectItem .Name .Path .Url) }}
{{ (projectItem .Name .Path .URL) }}
{{ end }}
tasks:
hello:
Expand Down Expand Up @@ -516,15 +516,15 @@ tasks:
}

// Update gitignore file if VCS set to git
hasUrl := false
hasURL := false
for _, project := range projects {
if project.Url != "" {
hasUrl = true
if project.URL != "" {
hasURL = true
break
}
}

if hasUrl && initFlags.SyncGitignore {
if hasURL && initFlags.SyncGitignore {
// Add gitignore file
gitignoreFilepath := filepath.Join(configDir, ".gitignore")
if _, err := os.Stat(gitignoreFilepath); os.IsNotExist(err) {
Expand All @@ -536,7 +536,7 @@ tasks:

var projectNames []string
for _, project := range projects {
if project.Url == "" {
if project.URL == "" {
continue
}

Expand All @@ -557,7 +557,7 @@ tasks:
fmt.Println("\nInitialized mani repository in", configDir)
fmt.Println("- Created mani.yaml")

if hasUrl && initFlags.SyncGitignore {
if hasURL && initFlags.SyncGitignore {
fmt.Println("- Created .gitignore")
}

Expand Down
38 changes: 22 additions & 16 deletions core/dao/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"path/filepath"
"regexp"
"slices"
"strings"

"gopkg.in/yaml.v3"
Expand All @@ -18,7 +19,7 @@ type Project struct {
Name string `yaml:"name"`
Path string `yaml:"path"`
Desc string `yaml:"desc"`
Url string `yaml:"url"`
URL string `yaml:"url"`
Clone string `yaml:"clone"`
Branch string `yaml:"branch"`
SingleBranch *bool `yaml:"single_branch"`
Expand All @@ -36,7 +37,7 @@ type Project struct {

type Remote struct {
Name string
Url string
URL string
}

func (p *Project) GetContext() string {
Expand Down Expand Up @@ -66,7 +67,7 @@ func (p Project) GetValue(key string, _ int) string {
case "Desc", "desc", "Description", "description":
return p.Desc
case "Url", "url":
return p.Url
return p.URL
case "Tag", "tag":
return strings.Join(p.Tags, ", ")
}
Expand Down Expand Up @@ -319,7 +320,7 @@ func (c Config) GetProjectsByName(projectNames []string) ([]Project, error) {
return matchedProjects, nil
}

// Projects must have all dirs to match.
// GetProjectsByPath Projects must have all dirs to match.
// If user provides a path which does not exist, then return error containing
// all the paths it didn't find.
// Supports glob patterns:
Expand Down Expand Up @@ -415,7 +416,7 @@ func (c Config) GetProjectsByPath(dirs []string) ([]Project, error) {
return projects, nil
}

// Projects must have all tags to match. For instance, if --tags frontend,backend
// GetProjectsByTags Projects must have all tags to match. For instance, if --tags frontend,backend
// is passed, then a project must have both tags.
// We only return error if the flags provided do not exist in the mani config.
func (c Config) GetProjectsByTags(tags []string) ([]Project, error) {
Expand Down Expand Up @@ -461,7 +462,7 @@ func (c Config) GetProjectsByTags(tags []string) ([]Project, error) {
return projects, nil
}

// Projects must have all tags to match. For instance, if --tags frontend,backend
// GetProjectsByTagsExpr Projects must have all tags to match. For instance, if --tags frontend,backend
// is passed, then a project must have both tags.
// We only return error if the tags provided do not exist.
func (c Config) GetProjectsByTagsExpr(tagsExpr string) ([]Project, error) {
Expand Down Expand Up @@ -508,7 +509,7 @@ out:
}

/**
* For each project path, get all the enumerations of dirnames.
* GetProjectPaths For each project path, get all the enumerations of dirnames.
* Example:
* Input:
* - /frontend/tools/project-a
Expand All @@ -530,7 +531,7 @@ func (c Config) GetProjectPaths() []string {
for i := 1; i <= len(ps); i++ {
p := filepath.Join(ps[0:i]...)

if p != "." && !core.StringInSlice(p, dirs) {
if p != "." && !slices.Contains(dirs, p) {
dirs = append(dirs, p)
}
}
Expand All @@ -552,8 +553,8 @@ func (c Config) GetProjectNames() []string {
func (c Config) GetProjectUrls() []string {
urls := []string{}
for _, project := range c.ProjectList {
if project.Url != "" {
urls = append(urls, project.Url)
if project.URL != "" {
urls = append(urls, project.URL)
}
}

Expand Down Expand Up @@ -610,11 +611,11 @@ func FindVCSystems(rootPath string) ([]Project, error) {
relPath, _ := filepath.Rel(rootPath, path)

var project Project
url, rErr := core.GetRemoteUrl(path)
url, rErr := core.GetRemoteURL(path)
if rErr != nil {
project = Project{Name: name, Path: relPath}
} else {
project = Project{Name: name, Path: relPath, Url: url}
project = Project{Name: name, Path: relPath, URL: url}
}

projects = append(projects, project)
Expand All @@ -628,13 +629,18 @@ func FindVCSystems(rootPath string) ([]Project, error) {
return projects, err
}

func UpdateProjectsToGitignore(projectNames []string, gitignoreFilename string) error {
func UpdateProjectsToGitignore(projectNames []string, gitignoreFilename string) (err error) {
l := list.New()
gitignoreFile, err := os.OpenFile(gitignoreFilename, os.O_RDWR, 0644)
if err != nil {
return &core.FailedToOpenFile{Name: gitignoreFilename}
}
defer gitignoreFile.Close()
defer func() {
closeErr := gitignoreFile.Close()
if err == nil {
err = closeErr
}
}()

scanner := bufio.NewScanner(gitignoreFile)
for scanner.Scan() {
Expand Down Expand Up @@ -711,15 +717,15 @@ func UpdateProjectsToGitignore(projectNames []string, gitignoreFilename string)
return nil
}

// List of remotes (key: value)
// ParseRemotes List of remotes (key: value)
func ParseRemotes(node yaml.Node) []Remote {
var remotes []Remote
count := len(node.Content)

for i := 0; i < count; i += 2 {
remote := Remote{
Name: node.Content[i].Value,
Url: node.Content[i+1].Value,
URL: node.Content[i+1].Value,
}

remotes = append(remotes, remote)
Expand Down
2 changes: 1 addition & 1 deletion core/dao/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func TestProject_GetValue(t *testing.T) {
Path: "/path/to/project",
RelPath: "relative/path",
Desc: "Test description",
Url: "https://example.com",
URL: "https://example.com",
Tags: []string{"frontend", "api"},
}

Expand Down
5 changes: 2 additions & 3 deletions core/dao/tag.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package dao

import (
"slices"
"strings"

"github.com/alajmo/mani/core"
)

type Tag struct {
Expand All @@ -26,7 +25,7 @@ func (c Config) GetTags() []string {
tags := []string{}
for _, project := range c.ProjectList {
for _, tag := range project.Tags {
if !core.StringInSlice(tag, tags) {
if !slices.Contains(tags, tag) {
tags = append(tags, tag)
}
}
Expand Down
Loading
Loading