workflow-direct: use correct remote name instead of origin
This commit is contained in:
@@ -106,7 +106,7 @@ func processConfiguredRepositoryAction(action *common.RepositoryWebhookEvent, co
|
|||||||
return fmt.Errorf("Error accessing/creating prjgit: %s/%s#%d err: %w", gitOrg, gitPrj, gitBranch, err)
|
return fmt.Errorf("Error accessing/creating prjgit: %s/%s#%d err: %w", gitOrg, gitPrj, gitBranch, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = git.GitClone(gitPrj, gitBranch, prjGitRepo.SSHURL)
|
remoteName, err := git.GitClone(gitPrj, gitBranch, prjGitRepo.SSHURL)
|
||||||
common.PanicOnError(err)
|
common.PanicOnError(err)
|
||||||
|
|
||||||
switch action.Action {
|
switch action.Action {
|
||||||
@@ -115,7 +115,7 @@ func processConfiguredRepositoryAction(action *common.RepositoryWebhookEvent, co
|
|||||||
return fmt.Errorf(" - '%s' repo is not sha256. Ignoring.", action.Repository.Name)
|
return fmt.Errorf(" - '%s' repo is not sha256. Ignoring.", action.Repository.Name)
|
||||||
}
|
}
|
||||||
common.PanicOnError(git.GitExec(gitPrj, "submodule", "--quiet", "add", "--depth", "1", action.Repository.Clone_Url, action.Repository.Name))
|
common.PanicOnError(git.GitExec(gitPrj, "submodule", "--quiet", "add", "--depth", "1", action.Repository.Clone_Url, action.Repository.Name))
|
||||||
defer func() { common.PanicOnError(git.GitExec(gitPrj, "submodule", "deinit", "--all")) }()
|
defer git.GitExecOrPanic(gitPrj, "submodule", "deinit", "--all")
|
||||||
|
|
||||||
branch := strings.TrimSpace(git.GitExecWithOutputOrPanic(path.Join(gitPrj, action.Repository.Name), "branch", "--show-current"))
|
branch := strings.TrimSpace(git.GitExecWithOutputOrPanic(path.Join(gitPrj, action.Repository.Name), "branch", "--show-current"))
|
||||||
if branch != config.Branch {
|
if branch != config.Branch {
|
||||||
@@ -139,7 +139,7 @@ func processConfiguredRepositoryAction(action *common.RepositoryWebhookEvent, co
|
|||||||
common.PanicOnError(git.GitExec(gitPrj, "rm", action.Repository.Name))
|
common.PanicOnError(git.GitExec(gitPrj, "rm", action.Repository.Name))
|
||||||
common.PanicOnError(git.GitExec(gitPrj, "commit", "-m", "Automatic package removal via Direct Workflow"))
|
common.PanicOnError(git.GitExec(gitPrj, "commit", "-m", "Automatic package removal via Direct Workflow"))
|
||||||
if !noop {
|
if !noop {
|
||||||
common.PanicOnError(git.GitExec(gitPrj, "push"))
|
git.GitExecOrPanic(gitPrj, "push", remoteName)
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -211,16 +211,16 @@ func processConfiguredPushAction(action *common.PushWebhookEvent, config *common
|
|||||||
git.GitExecOrPanic(gitPrj, "submodule", "update", "--init", "--depth", "1", "--checkout", action.Repository.Name)
|
git.GitExecOrPanic(gitPrj, "submodule", "update", "--init", "--depth", "1", "--checkout", action.Repository.Name)
|
||||||
defer git.GitExecOrPanic(gitPrj, "submodule", "deinit", "--all")
|
defer git.GitExecOrPanic(gitPrj, "submodule", "deinit", "--all")
|
||||||
|
|
||||||
if err := git.GitExec(filepath.Join(gitPrj, action.Repository.Name), "fetch", "--depth", "1", "--force", "origin", config.Branch+":"+config.Branch); err != nil {
|
if err := git.GitExec(filepath.Join(gitPrj, action.Repository.Name), "fetch", "--depth", "1", "--force", remoteName, config.Branch+":"+config.Branch); err != nil {
|
||||||
return fmt.Errorf("error fetching branch %s. ignoring as non-existent. err: %w", config.Branch, err) // no branch? so ignore repo here
|
return fmt.Errorf("error fetching branch %s. ignoring as non-existent. err: %w", config.Branch, err) // no branch? so ignore repo here
|
||||||
}
|
}
|
||||||
id, err := git.GitRemoteHead(filepath.Join(gitPrj, action.Repository.Name), "origin", config.Branch)
|
id, err := git.GitRemoteHead(filepath.Join(gitPrj, action.Repository.Name), remoteName, config.Branch)
|
||||||
common.PanicOnError(err)
|
common.PanicOnError(err)
|
||||||
if action.Head_Commit.Id == id {
|
if action.Head_Commit.Id == id {
|
||||||
git.GitExecOrPanic(filepath.Join(gitPrj, action.Repository.Name), "checkout", id)
|
git.GitExecOrPanic(filepath.Join(gitPrj, action.Repository.Name), "checkout", id)
|
||||||
git.GitExecOrPanic(gitPrj, "commit", "-a", "-m", "Automatic update via push via Direct Workflow")
|
git.GitExecOrPanic(gitPrj, "commit", "-a", "-m", "Automatic update via push via Direct Workflow")
|
||||||
if !noop {
|
if !noop {
|
||||||
git.GitExecOrPanic(gitPrj, "push")
|
git.GitExecOrPanic(gitPrj, "push", remoteName)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -246,9 +246,9 @@ func verifyProjectState(git common.Git, org string, config *common.AutogitConfig
|
|||||||
return fmt.Errorf("Error fetching or creating '%s/%s' -- aborting verifyProjectState(). Err: %w", gitOrg, gitPrj, err)
|
return fmt.Errorf("Error fetching or creating '%s/%s' -- aborting verifyProjectState(). Err: %w", gitOrg, gitPrj, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = git.GitClone(gitPrj, gitBranch, repo.SSHURL)
|
remoteName, err := git.GitClone(gitPrj, gitBranch, repo.SSHURL)
|
||||||
common.PanicOnError(err)
|
common.PanicOnError(err)
|
||||||
defer func() { common.PanicOnError(git.GitExec(gitPrj, "submodule", "deinit", "--all")) }()
|
defer git.GitExecOrPanic(gitPrj, "submodule", "deinit", "--all")
|
||||||
|
|
||||||
log.Println(" * Getting submodule list")
|
log.Println(" * Getting submodule list")
|
||||||
sub, err := git.GitSubmoduleList(gitPrj, "HEAD")
|
sub, err := git.GitSubmoduleList(gitPrj, "HEAD")
|
||||||
@@ -419,7 +419,7 @@ next_repo:
|
|||||||
if isGitUpdated {
|
if isGitUpdated {
|
||||||
common.PanicOnError(git.GitExec(gitPrj, "commit", "-a", "-m", "Automatic update via push via Direct Workflow -- SYNC"))
|
common.PanicOnError(git.GitExec(gitPrj, "commit", "-a", "-m", "Automatic update via push via Direct Workflow -- SYNC"))
|
||||||
if !noop {
|
if !noop {
|
||||||
common.PanicOnError(git.GitExec(gitPrj, "push"))
|
git.GitExecOrPanic(gitPrj, "push", remoteName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user