workflow-direct: add no-op mode, for debugging
This commit is contained in:
@@ -125,7 +125,9 @@ func processConfiguredRepositoryAction(action *common.RepositoryWebhookEvent, co
|
||||
common.PanicOnError(git.GitExec(path.Join(gitPrj, action.Repository.Name), "checkout", config.Branch))
|
||||
}
|
||||
common.PanicOnError(git.GitExec(gitPrj, "commit", "-m", "Automatic package inclusion via Direct Workflow"))
|
||||
common.PanicOnError(git.GitExec(gitPrj, "push"))
|
||||
if !noop {
|
||||
common.PanicOnError(git.GitExec(gitPrj, "push"))
|
||||
}
|
||||
|
||||
case "deleted":
|
||||
if stat, err := os.Stat(filepath.Join(git.GetPath(), gitPrj, action.Repository.Name)); err != nil || !stat.IsDir() {
|
||||
@@ -136,7 +138,9 @@ func processConfiguredRepositoryAction(action *common.RepositoryWebhookEvent, co
|
||||
}
|
||||
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, "push"))
|
||||
if !noop {
|
||||
common.PanicOnError(git.GitExec(gitPrj, "push"))
|
||||
}
|
||||
|
||||
default:
|
||||
return fmt.Errorf("%s: %s", "Unknown action type", action.Action)
|
||||
@@ -207,7 +211,9 @@ func processConfiguredPushAction(action *common.PushWebhookEvent, config *common
|
||||
common.PanicOnError(git.GitExec(filepath.Join(gitPrj, action.Repository.Name), "fetch", "--depth", "1", "origin", id))
|
||||
common.PanicOnError(git.GitExec(filepath.Join(gitPrj, action.Repository.Name), "checkout", id))
|
||||
common.PanicOnError(git.GitExec(gitPrj, "commit", "-a", "-m", "Automatic update via push via Direct Workflow"))
|
||||
common.PanicOnError(git.GitExec(gitPrj, "push"))
|
||||
if !noop {
|
||||
common.PanicOnError(git.GitExec(gitPrj, "push"))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -263,10 +269,10 @@ next_package:
|
||||
for filename, commitId := range sub {
|
||||
// ignore project gits
|
||||
//for _, c := range configs {
|
||||
if gitPrj == filename {
|
||||
log.Println(" prjgit as package? ignoring project git:", filename)
|
||||
continue next_package
|
||||
}
|
||||
if gitPrj == filename {
|
||||
log.Println(" prjgit as package? ignoring project git:", filename)
|
||||
continue next_package
|
||||
}
|
||||
//}
|
||||
|
||||
log.Println(" verifying package:", filename, commitId, config.Branch)
|
||||
@@ -310,7 +316,9 @@ next_package:
|
||||
|
||||
nCommits := len(common.SplitStringNoEmpty(git.GitExecWithOutputOrPanic(pkgPath, "rev-list", "^NOW", "HEAD"), "\n"))
|
||||
if nCommits > 0 {
|
||||
git.GitExecOrPanic(pkgPath, "push", "-f", "origin", "HEAD:"+config.Branch)
|
||||
if !noop {
|
||||
git.GitExecOrPanic(pkgPath, "push", "-f", "origin", "HEAD:"+config.Branch)
|
||||
}
|
||||
isGitUpdated = true
|
||||
}
|
||||
|
||||
@@ -361,12 +369,12 @@ next_repo:
|
||||
continue next_repo
|
||||
}
|
||||
|
||||
// for _, c := range configs {
|
||||
if gitPrj == r.Name {
|
||||
// ignore project gits
|
||||
continue next_repo
|
||||
}
|
||||
// }
|
||||
// for _, c := range configs {
|
||||
if gitPrj == r.Name {
|
||||
// ignore project gits
|
||||
continue next_repo
|
||||
}
|
||||
// }
|
||||
|
||||
for repo := range sub {
|
||||
if repo == r.Name {
|
||||
@@ -403,7 +411,9 @@ next_repo:
|
||||
|
||||
if isGitUpdated {
|
||||
common.PanicOnError(git.GitExec(gitPrj, "commit", "-a", "-m", "Automatic update via push via Direct Workflow -- SYNC"))
|
||||
common.PanicOnError(git.GitExec(gitPrj, "push"))
|
||||
if !noop {
|
||||
common.PanicOnError(git.GitExec(gitPrj, "push"))
|
||||
}
|
||||
}
|
||||
|
||||
if DebugMode {
|
||||
@@ -414,6 +424,7 @@ next_repo:
|
||||
}
|
||||
|
||||
var checkOnStart bool
|
||||
var noop bool
|
||||
var checkInterval time.Duration
|
||||
|
||||
func checkOrg(org string, configs []*common.AutogitConfig) {
|
||||
@@ -495,6 +506,7 @@ func main() {
|
||||
giteaUrl := flag.String("gitea-url", "https://src.opensuse.org", "Gitea instance")
|
||||
rabbitUrl := flag.String("url", "amqps://rabbit.opensuse.org", "URL for RabbitMQ instance")
|
||||
flag.BoolVar(&DebugMode, "debug", false, "Extra debugging information")
|
||||
flag.BoolVar(&noop, "no-op", false, "No-op mode. Do not push changes to remote repo.")
|
||||
flag.BoolVar(&checkOnStart, "check-on-start", false, "Check all repositories for consistency on start, without delays")
|
||||
checkIntervalHours := flag.Float64("check-interval", 5, "Check interval (+-random delay) for repositories for consitency, in hours")
|
||||
basePath := flag.String("repo-path", "", "Repository path. Default is temporary directory")
|
||||
|
||||
Reference in New Issue
Block a user