Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
automirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
INP-net
automirror
Commits
3729a7fc
Verified
Commit
3729a7fc
authored
5 months ago
by
Gwen Le Bihan
Committed by
Ewen Le Bihan
5 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Allow renaming repos completely
parent
d2cc8299
Loading
Loading
No related merge requests found
Pipeline
#18502
passed
5 months ago
Stage: build
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Justfile
+3
-0
3 additions, 0 deletions
Justfile
config.schema.json
+8
-0
8 additions, 0 deletions
config.schema.json
main.go
+21
-12
21 additions, 12 deletions
main.go
with
32 additions
and
12 deletions
Justfile
+
3
−
0
View file @
3729a7fc
...
...
@@ -5,3 +5,6 @@ dev:
build:
go build -o bin/main main.go
updateschema:
go run main.go --print-jsonschema > config.schema.json
This diff is collapsed.
Click to expand it.
config.schema.json
+
8
−
0
View file @
3729a7fc
...
...
@@ -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
,
...
...
This diff is collapsed.
Click to expand it.
main.go
+
21
−
12
View file @
3729a7fc
...
...
@@ -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
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment