[patch] Add `-rebase-branch`
Ideally Jiri would have someday learned about auth and been able to
fetch this dynamically but for now Infra can feed the correct
value/document the correct incantation to rebase correctly when dealing
with branches. I had alternatively considered using the manifest branch
as the value in fillDefaults() however that is a far more invasive
change and would potentially cause other issues.
Bug: 69324
Change-Id: Ic23c4403564ac62b0adbef0c1ea17b2be3e9017f
Reviewed-on: https://fuchsia-review.googlesource.com/c/jiri/+/504398
Reviewed-by: Anthony Fandrianto <atyfto@google.com>
Commit-Queue: Nathan Mulcahey <nmulcahey@google.com>
diff --git a/cmd/jiri/patch.go b/cmd/jiri/patch.go
index f320429..eb8ff9a 100644
--- a/cmd/jiri/patch.go
+++ b/cmd/jiri/patch.go
@@ -22,6 +22,7 @@
var (
patchRebaseFlag bool
patchRebaseRevision string
+ patchRebaseBranch string
patchTopicFlag bool
patchBranchFlag string
patchDeleteFlag bool
@@ -39,6 +40,7 @@
cmdPatch.Flags.BoolVar(&patchForceFlag, "force", false, "Use force when deleting the existing branch")
cmdPatch.Flags.BoolVar(&patchRebaseFlag, "rebase", false, "Rebase the change after downloading")
cmdPatch.Flags.StringVar(&patchRebaseRevision, "rebase-revision", "", "Rebase the change to a specific revision after downloading")
+ cmdPatch.Flags.StringVar(&patchRebaseBranch, "rebase-branch", "", "The branch to rebase the change onto")
cmdPatch.Flags.StringVar(&patchHostFlag, "host", "", `Gerrit host to use. Defaults to gerrit host specified in manifest.`)
cmdPatch.Flags.StringVar(&patchProjectFlag, "project", "", `Project to apply patch to. This cannot be passed with topic flag.`)
cmdPatch.Flags.BoolVar(&patchTopicFlag, "topic", false, `Patch whole topic.`)
@@ -326,8 +328,10 @@
return noSuchProjectErr
}
// TODO: TO-592 - remove this hardcode
- if p.RemoteBranch != "" {
+ if patchRebaseBranch == "" && p.RemoteBranch != "" {
remoteBranch = p.RemoteBranch
+ } else if patchRebaseBranch != "" {
+ remoteBranch = patchRebaseBranch
} else {
remoteBranch = "master"
}