This commit is contained in:
2025-04-17 00:38:53 +02:00
parent 5895e3d02c
commit d65f37739c
2 changed files with 9 additions and 4 deletions

View File

@@ -122,12 +122,15 @@ func AllocateGitWorkTree(basePath, gitAuthor, email string) (GitHandlerGenerator
func (s *gitHandlerGeneratorImpl) CreateGitHandler(org string) (Git, error) { func (s *gitHandlerGeneratorImpl) CreateGitHandler(org string) (Git, error) {
path := path.Join(s.path, org) path := path.Join(s.path, org)
if fs, err := os.Stat(s.path); err != nil || !fs.IsDir() { if fs, err := os.Stat(path); (err != nil && !os.IsNotExist(err)) || (err == nil && !fs.IsDir()) {
return nil, err return nil, err
} else if os.IsNotExist(err) { } else if err != nil && os.IsNotExist(err) {
log.Println("creating dirs")
if err := os.MkdirAll(path, 0o777); err != nil && !os.IsExist(err) { if err := os.MkdirAll(path, 0o777); err != nil && !os.IsExist(err) {
return nil, err return nil, err
} }
} else {
log.Println(fs, err)
} }
return s.ReadExistingPath(org) return s.ReadExistingPath(org)
@@ -210,8 +213,10 @@ func (e *GitHandlerImpl) GitClone(repo, branch, remoteUrl string) error {
} }
remoteName := remoteUrlComp.RemoteName() remoteName := remoteUrlComp.RemoteName()
log.Println("Clone", *remoteUrlComp, " -> ", remoteName)
if fi, err := os.Stat(path.Join(e.GitPath, repo)); os.IsNotExist(err) { if fi, err := os.Stat(path.Join(e.GitPath, repo)); os.IsNotExist(err) {
if err = e.GitExec("", "clone", remoteUrl, repo); err != nil { if err = e.GitExec("", "clone", "--origin", remoteName, remoteUrl, repo); err != nil {
return err return err
} }
} else if err != nil || !fi.IsDir() { } else if err != nil || !fi.IsDir() {

View File

@@ -108,7 +108,7 @@ func processConfiguredRepositoryAction(action *common.RepositoryWebhookEvent, co
} }
if _, err := fs.Stat(os.DirFS(git.GetPath()), config.GitProjectName); errors.Is(err, os.ErrNotExist) { if _, err := fs.Stat(os.DirFS(git.GetPath()), config.GitProjectName); errors.Is(err, os.ErrNotExist) {
common.PanicOnError(git.GitClone(gitPrj, config.Branch, prjGitRepo.SSHURL)) common.PanicOnError(git.GitClone(gitPrj, gitBranch, prjGitRepo.SSHURL))
} }
switch action.Action { switch action.Action {