unique org_repo remote names

This commit is contained in:
2025-04-15 14:55:19 +02:00
parent 8645063e8d
commit ed815c3ad1
3 changed files with 69 additions and 5 deletions

View File

@@ -86,13 +86,12 @@ type GitHandlerGenerator interface {
}
type gitHandlerGeneratorImpl struct {
// TODO: add mutex to lock paths so only one workflow per path and others wait
path string
git_author string
email string
lock_lock sync.Mutex
lock map[string]sync.Mutex
lock map[string]*sync.Mutex // per org
}
func AllocateGitWorkTree(basePath, gitAuthor, email string) (GitHandlerGenerator, error) {
@@ -117,7 +116,7 @@ func AllocateGitWorkTree(basePath, gitAuthor, email string) (GitHandlerGenerator
git_author: gitAuthor,
email: email,
lock: make(map[string]sync.Mutex),
lock: make(map[string]*sync.Mutex),
}, nil
}
@@ -193,7 +192,11 @@ func (e *GitHandlerImpl) GitClone(repo, branch, remoteUrl string) error {
return fmt.Errorf("Clone location not a directory or Stat error: %w", err)
}
remoteName := ""
remoteUrlComp, err := ParseGitRemoteUrl(remoteUrl)
if err != nil {
return fmt.Errorf("Cannot parse remote URL: %w", err)
}
remoteName := remoteUrlComp.RemoteName()
clonedRemote := strings.TrimSpace(e.GitExecWithOutputOrPanic(repo, "remote", "get-url", remoteName))
if clonedRemote != remoteUrl {
e.GitExecOrPanic(repo, "remote", "set-url", remoteName, remoteUrl)