mirror of
https://github.com/outbackdingo/ghorg.git
synced 2026-01-27 10:19:03 +00:00
Add filename length limit on gitlab repos with name collisions (#242)
This commit is contained in:
@@ -3,6 +3,15 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
||||
|
||||
## [1.8.8] - unreleased
|
||||
### Added
|
||||
- Filename length limit on gitlab repos with name collisions
|
||||
### Changed
|
||||
### Deprecated
|
||||
### Removed
|
||||
### Fixed
|
||||
### Security
|
||||
|
||||
## [1.8.7] - 7/19/22
|
||||
### Added
|
||||
### Changed
|
||||
|
||||
18
cmd/clone.go
18
cmd/clone.go
@@ -470,6 +470,15 @@ func printDryRun(repos []scm.Repo) {
|
||||
}
|
||||
}
|
||||
|
||||
func trimCollisionFilename(filename string) string {
|
||||
maxLen := 248
|
||||
if len(filename) > maxLen {
|
||||
return filename[:strings.LastIndex(filename[:maxLen], "_")]
|
||||
}
|
||||
|
||||
return filename
|
||||
}
|
||||
|
||||
// CloneAllRepos clones all repos
|
||||
func CloneAllRepos(git git.Gitter, cloneTargets []scm.Repo) {
|
||||
// Filter repos that have attributes that don't need specific scm api calls
|
||||
@@ -558,7 +567,14 @@ func CloneAllRepos(git git.Gitter, cloneTargets []scm.Repo) {
|
||||
// Only GitLab repos can have collisions due to groups and subgroups
|
||||
// If there are collisions and this is a repo with a naming collision change name to avoid collisions
|
||||
if hasCollisions && repoNameWithCollisions[repo.Name] {
|
||||
repoSlug = strings.Replace(repo.Path, "/", "_", -1)
|
||||
repoSlug = trimCollisionFilename(strings.Replace(repo.Path, "/", "_", -1))
|
||||
|
||||
// If a collision has another collision with trimmed name append a number
|
||||
if _, ok := repoNameWithCollisions[repoSlug]; ok {
|
||||
repoSlug = fmt.Sprintf("_%v_%v", strconv.Itoa(i), repoSlug)
|
||||
} else {
|
||||
repoNameWithCollisions[repoSlug] = true
|
||||
}
|
||||
}
|
||||
|
||||
repo.HostPath = filepath.Join(outputDirAbsolutePath, repoSlug)
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const ghorgVersion = "v1.8.7"
|
||||
const ghorgVersion = "v1.8.8"
|
||||
|
||||
var versionCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
|
||||
Reference in New Issue
Block a user