Commit graph

192 commits

Author SHA1 Message Date
Tyler McGoffin
322a43feff Change error handling on ReadBranchConfig to respect git Exit Codes 2025-01-10 09:59:21 -08:00
Tyler McGoffin
48d45d0b9d Refactor error handling in ReadBranchConfig to avoid panic 2025-01-09 11:45:45 -08:00
Tyler McGoffin
e1423cdbbf Refine error handling of ReadBranchConfig
cmd.Output() will return an error when the git command ran successfully
but had no output. To handle this, we can check Stderr, as we expect it to
be populated for any ExitErrors or otherwise when there is a command
failure.

This allows for propagation of this error handling up the call chain, so
we are now returning errors if the call to git fails instead of just
handing off an empty BranchConfig and suppressing the errors.

Additionally, I've removed some more naked returns that I found in
pkg/cmd/pr/create.go createRun
2025-01-09 11:45:15 -08:00
Tyler McGoffin
527d1db298 Add missing test for RemoteURL in parseBranchConfig 2025-01-08 14:24:20 -08:00
Tyler McGoffin
4575692ebf Remove private readBranchConfig method and remove parseBranchConfig from Client
I think I went too far with my previous refactor and am backing out of it.
Adding a private readBranchConfig method on the client wasn't providing
any real additional value, so I've put it back into ReadBranchConfig.

However, I think there is still value in having parseBranchConfig
(formerly createBranchConfig) as a separate util function, as it both
improves readability of ReadBranchConfig and makes parsing its purpose
easier through the bespoke tests for it.
2025-01-08 10:36:45 -08:00
Tyler McGoffin
0137150848 Refactor Test_readGitBranchConfig for easier parsing 2025-01-07 14:56:27 -08:00
Tyler McGoffin
f43da8ea9a Refactor ReadBranchConfig for test coverage of newly returned erros 2025-01-07 13:54:43 -08:00
Tyler McGoffin
bf6fdbdfd2 Remove named returns from ReadBranchConfig and surface errors 2025-01-07 13:54:43 -08:00
William Martin
8b5073d617 Move trackingRef into pr create package 2025-01-06 10:33:28 -06:00
William Martin
dc077dc09b Panic if tracking ref can't be reconstructed 2025-01-06 10:33:28 -06:00
William Martin
3ae4e5da20 Document and rework pr create tracking branch lookup 2025-01-06 10:33:28 -06:00
Caleb Brose
9d490547b8
Alternative: remove LocalBranch from BranchConfig 2025-01-03 20:39:12 +00:00
Caleb Brose
7a1052ca33
Set LocalBranch even if the git config fails 2025-01-03 20:35:48 +00:00
Heath Stewart
5da86e07e7
Merge changes from #10004
Merges changes from @williammartin including acceptance tests and word changes.

Co-authored-by: William Martin <williammartin@github.com>
2024-12-08 20:34:21 -08:00
Heath Stewart
88b96f411c
Set gh-merge-base from issue develop 2024-12-08 17:40:03 -08:00
Heath Stewart
3d139019f8
Open PR against gh-merge-base
Partly resolves issue #8979 by checking for a `gh-merge-base` branch tag and using that as though it were passed to `gh pr create --base`.
2024-12-08 17:40:00 -08:00
William Martin
694e565384 Fix PR checkout panic when base repo is not in remotes 2024-12-02 17:20:57 +01:00
bagtoad
76f1553fb9 Fix formatting in client_test.go comments for linter 2024-11-27 14:19:27 -07:00
William Martin
ec086a021b
Update git/client_test.go
Co-authored-by: Andy Feller <andyfeller@github.com>
2024-11-27 15:51:44 +01:00
William Martin
622e283d2b
Update git/client_test.go
Co-authored-by: Andy Feller <andyfeller@github.com>
2024-11-27 15:51:38 +01:00
William Martin
21a14a7d1a
Update git/client_test.go
Co-authored-by: Andy Feller <andyfeller@github.com>
2024-11-27 15:50:54 +01:00
William Martin
72a6fd00a4 Rename backwards compatible credentials pattern 2024-11-27 12:21:55 +01:00
William Martin
0b4f087b46 Fix CredentialPattern doc typos
Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>
2024-11-27 12:07:04 +01:00
William Martin
3773068f58 Remove TODOs 2024-11-27 12:06:17 +01:00
Tyler McGoffin
ad397bd0a6 Fix typos and add tests for CredentialPatternFrom* functions 2024-11-26 16:08:51 -08:00
William Martin
0db05ff022 Add SSH remote todo 2024-11-26 22:30:19 +01:00
William Martin
efd8ff6d46 General cleanup and docs 2024-11-26 22:30:11 +01:00
William Martin
6b7f1ff060 Allow client fetch to use insecure credentials pattern 2024-11-26 22:30:03 +01:00
William Martin
7affcadb5e Allow client push to use insecure credential pattern 2024-11-26 22:29:58 +01:00
William Martin
75712de712 Allow client pull to use insecure credential pattern 2024-11-26 22:29:51 +01:00
William Martin
5f5c5270c9 Allow opt-in to insecure pattern 2024-11-26 22:29:43 +01:00
William Martin
46922694dc Support secure credential pattern 2024-11-26 22:29:38 +01:00
Hiran Wijesinghe
fd51a69308
Handle --bare clone targets (#9271)
Co-authored-by: Andy Feller <andyfeller@github.com>
2024-07-24 12:35:24 +02:00
William Martin
3aa3d61108
Merge pull request #8929 from cli/wm/parse-url-no-nakaed-return
Remove naked returns from git ParseURL
2024-04-05 16:33:09 +02:00
William Martin
b0b147e60c Use testify in git url tests 2024-04-05 16:07:04 +02:00
William Martin
1b57b0f917 Minorly refactor scheme normalization in git ParseURL 2024-04-05 12:29:27 +02:00
William Martin
2c2a09c73e Test for parsing error in git ParseURL 2024-04-05 12:25:24 +02:00
William Martin
27f3d62d02 Remove naked returns from git ParseURL 2024-04-05 12:23:47 +02:00
Babak K. Shandiz
47efef6d70
Fix parsing IPv6 remote URLs (#8893)
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
2024-04-05 11:54:55 +02:00
William Martin
5fe6eebfea Update incorrect regex comment for client Commits 2024-02-28 13:38:39 +01:00
William Martin
2ee6737053 Use regex to split apart the git client Commit logs
Theoretically this should be clearer and more robust than the previous
version which had some custom loop logic while trying to parse newlines
and determine whether it had reached a new commit entry by trying to parse
a git sha. This would not have worked correctly if a commit body contained
a sha on a new line.
2024-02-27 20:49:00 +01:00
William Martin
2b0484f5aa Use null byte separators when fetching comments from git 2024-02-27 18:00:40 +01:00
William Martin
fb353caf19 Add new tests to git client Commits
This adds coverage for mutliple commits and commits with
newlines in bodies.
2024-02-27 17:33:17 +01:00
William Martin
2af0c899d8 Remove unnecessary split conditional from client Commits
Since this is guarded by the line starting with a git sha, it must
be a line of the form 'sha,title,body', so there can never be only
two entries since the Split fn will produce an empty string in the
last spot in the case of a missing body.
2024-02-27 17:26:51 +01:00
William Martin
0541d286c1 Extract new test helper for git client Commits 2024-02-27 14:41:45 +01:00
Federico Guerinoni
42613172bd pr: Add flag fillverbose
This is used to fill the body of PR with all commits msg + body
of every commits because there can be lot of useful information.

Signed-off-by: Federico Guerinoni <guerinoni.federico@gmail.com>
2024-02-01 09:12:04 +01:00
Federico Guerinoni
6dfae58b47 git: Return body from list of commits
This allow to use body of every commits between two ref.
2024-02-01 09:09:06 +01:00
Sam Coe
08fb744229
Simplify git AddRemote to remove unused arg (#8392) 2023-12-04 15:48:08 -04:00
Keming
ba60f89f42
Delete local tag when running gh release delete --cleanup-tag (#7884) 2023-09-07 12:04:15 +00:00
Sam Coe
fac497108b
Set upstream remote to track all branches after initial fetch (#7542) 2023-06-12 09:23:56 +09:00