Refactor finder.Find and replace parseCurrentBranch with parsePRRefs
I've been struggling horribly to reason through all of this code, and
after much mental gymnastics I identified the culprit as the overloaded
"branch" string returned by parseCurrentBranch.
This value was either the name of the branch that the PR we're looking for
is associated with, or that name prepended with the owner's name and a :
if we're on a branch, so:
PR branch: featureBranch
branch == "featureBranch"
If on Fork belonging to "ForkOwner"
branch == "ForkOwner:featureBranch"
Since this extra information was bundled up into this single string, it
complicated the responsibilities of parseCurrentBranch's "branch" return
value. Thus, I've teased out "branch" into the new PRRefs struct:
type PRRefs struct{
BranchName string
HeadRepo ghrepo.Interface
BaseRepo ghrepo.Interface
}
This allows the new parsePRRefs function to move all the previous
"branch" string's information into structured data, and allows for a new
method on PRRefs, GetPRLabel(), to create the string that "branch"
previously held to pass into its downstream consumer, namely
findForBranch.
This also allowed for better test coverage, directly connecting the PRRefs
fields to the values contained in the git config. Overall, I am now
confident that this is doing what its supposed to do with respect to my
understanding of the various central and triangular git workflows we are
addressing.
This commit is contained in:
parent
aef2642581
commit
41729b004d
3 changed files with 540 additions and 286 deletions
|
|
@ -64,8 +64,10 @@ type BranchConfig struct {
|
|||
RemoteName string
|
||||
RemoteURL *url.URL
|
||||
// MergeBase is the optional base branch to target in a new PR if `--base` is not specified.
|
||||
MergeBase string
|
||||
MergeRef string
|
||||
MergeBase string
|
||||
MergeRef string
|
||||
// These are used to handle triangular workflows. They can be defined by either
|
||||
// a remote.pushDefault or a branch.<name>.pushremote value set on the git config.
|
||||
RemotePushDefault string
|
||||
PushRemoteURL *url.URL
|
||||
PushRemoteName string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue