Skip to content
Snippets Groups Projects
Verified Commit 3729a7fc authored by Gwen Le Bihan's avatar Gwen Le Bihan Committed by Ewen Le Bihan
Browse files

:sparkles: Allow renaming repos completely

parent d2cc8299
No related merge requests found
Pipeline #18502 passed
......@@ -5,3 +5,6 @@ dev:
build:
go build -o bin/main main.go
updateschema:
go run main.go --print-jsonschema > config.schema.json
......@@ -26,6 +26,10 @@
"prefix": { "type": "string" },
"suffix": { "type": "string" },
"topics": { "items": { "type": "string" }, "type": "array" },
"renames": {
"additionalProperties": { "type": "string" },
"type": "object"
},
"subgroups": {
"properties": { "flatten": { "type": "string" } },
"additionalProperties": false,
......@@ -44,6 +48,10 @@
"prefix": { "type": "string" },
"suffix": { "type": "string" },
"topics": { "items": { "type": "string" }, "type": "array" },
"renames": {
"additionalProperties": { "type": "string" },
"type": "object"
},
"subgroups": {
"properties": { "flatten": { "type": "string" } },
"additionalProperties": false,
......
......@@ -15,8 +15,8 @@ import (
"golang.org/x/exp/slices"
"dario.cat/mergo"
ll "github.com/ewen-lbh/label-logger-go"
"github.com/google/uuid"
ll "github.com/gwennlbh/label-logger-go"
"github.com/invopop/jsonschema"
"github.com/joho/godotenv"
"gopkg.in/yaml.v3"
......@@ -28,6 +28,7 @@ type MirrorDefaults struct {
Prefix string `json:"prefix,omitempty"`
Suffix string `json:"suffix,omitempty"`
Topics []string `json:"topics,omitempty"`
Renames map[string]string `json:"renames,omitempty"`
Subgroups struct {
Flatten string `json:"flatten"`
} `json:"subgroups,omitempty"`
......@@ -40,6 +41,7 @@ type MirrorDefinition struct {
Prefix string `json:"prefix,omitempty"`
Suffix string `json:"suffix,omitempty"`
Topics []string `json:"topics,omitempty"`
Renames map[string]string `json:"renames,omitempty"`
Subgroups struct {
Flatten string `json:"flatten"`
} `json:"subgroups,omitempty"`
......@@ -154,6 +156,7 @@ func githubOrgConfig(org string) ([]MirrorDefinition, bool) {
Suffix: config.Defaults.Suffix,
Topics: config.Defaults.Topics,
Subgroups: config.Defaults.Subgroups,
Renames: config.Defaults.Renames,
})
}
return merged, true
......@@ -401,6 +404,12 @@ func setGitLabMirror(repo map[string]interface{}, githubName string, githubOrg s
func githubNameFromGitlabPath(path string, mirrorConfigUsed MirrorDefinition) string {
pathParts := strings.Split(path, "/")[1:]
path = strings.Join(pathParts, mirrorConfigUsed.Subgroups.Flatten)
for from, to := range mirrorConfigUsed.Renames {
if from == path {
path = to
break
}
}
path = fmt.Sprintf("%s%s%s", mirrorConfigUsed.Prefix, path, mirrorConfigUsed.Suffix)
return path
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment