cli/git
Tyler McGoffin 41729b004d 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.
2025-01-23 15:25:28 -08:00
..
fixtures Refactor code to live inside default pkg 2022-05-18 08:40:30 +02:00
client.go fixup! Add comments and a bit of code cleanup 2025-01-16 15:07:33 +11:00
client_test.go Add comments and a bit of code cleanup 2025-01-15 16:13:03 -08:00
command.go Allow client push to use insecure credential pattern 2024-11-26 22:29:58 +01:00
errors.go Refactor git client and add tests (#6525) 2022-11-03 11:58:38 +01:00
objects.go Refactor finder.Find and replace parseCurrentBranch with parsePRRefs 2025-01-23 15:25:28 -08:00
url.go Merge pull request #8929 from cli/wm/parse-url-no-nakaed-return 2024-04-05 16:33:09 +02:00
url_test.go Merge pull request #8929 from cli/wm/parse-url-no-nakaed-return 2024-04-05 16:33:09 +02:00