-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set upstream remote to track all branches after initial fetch #7542
Conversation
func (c *Client) IsLocalGitRepo(ctx context.Context) (bool, error) { | ||
_, err := c.GitDir(ctx) | ||
if err != nil { | ||
var execError errWithExitCode | ||
if errors.As(err, &execError) && execError.ExitCode() == 128 { | ||
return false, nil | ||
} | ||
return false, err | ||
} | ||
return true, nil | ||
} | ||
|
||
func (c *Client) UnsetRemoteResolution(ctx context.Context, name string) error { | ||
args := []string{"config", "--unset", fmt.Sprintf("remote.%s.gh-resolved", name)} | ||
cmd, err := c.Command(ctx, args...) | ||
if err != nil { | ||
return err | ||
} | ||
_, err = cmd.Output() | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These just got moved upwards in the file, no actual changes to the methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me! Thanks.
gc := gitClient.Copy() | ||
gc.RepoDir = cloneDir | ||
|
||
_, err = gc.AddRemote(ctx, upstreamName, upstreamURL, []string{canonicalRepo.Parent.DefaultBranchRef.Name}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know about you but I kind of like the WithRepoDir
modifier pattern, it's just a shame that it doesn't "put it back the way it was" so to speak.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not exactly following. The WithRepoDir
modifier does keep the git client directory unchanged and just modifies the single command, but in this case we were now up to 3 commands that needed to be modified so it seemed like an appropriate time to create a new git client specifically targeted at the cloneDir
directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake! I thought it modified the RepoDir
field on the git client rather than appending a -C
just for this command.
I actually quite like that pattern even if used multiple times. Generally, I find copy semantics in languages with limited mutation control to be difficult to reason about and a regular source of "oops I modified this thing here and I didn't expect it to be modified there".
Not a worry for this though, I think it's a sensible pattern to explore. Thanks for the correction.
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [aquaproj/aqua-registry](https://github.com/aquaproj/aqua-registry) | minor | `v4.20.0` -> `v4.21.1` | | [cli/cli](https://github.com/cli/cli) | minor | `v2.30.0` -> `v2.31.0` | | [weaveworks/eksctl](https://github.com/weaveworks/eksctl) | minor | `v0.145.0` -> `v0.146.0` | | [zellij-org/zellij](https://github.com/zellij-org/zellij) | patch | `v0.37.1` -> `v0.37.2` | --- ### Release Notes <details> <summary>aquaproj/aqua-registry</summary> ### [`v4.21.1`](https://github.com/aquaproj/aqua-registry/releases/tag/v4.21.1) [Compare Source](https://github.com/aquaproj/aqua-registry/compare/v4.21.0...v4.21.1) [Issues](https://github.com/aquaproj/aqua-registry/issues?q=is%3Aissue+milestone%3Av4.21.1) | [Pull Requests](https://github.com/aquaproj/aqua-registry/pulls?q=is%3Apr+milestone%3Av4.21.1) | aquaproj/aqua-registry@v4.21.0...v4.21.1 #### Fixes [#​13199](https://github.com/aquaproj/aqua-registry/issues/13199) kubernetes-sigs/kustomize: Follow up changes of kustomize v5.1.0 - [https://github.com/kubernetes-sigs/kustomize/issues/5220](https://github.com/kubernetes-sigs/kustomize/issues/5220) ### [`v4.21.0`](https://github.com/aquaproj/aqua-registry/releases/tag/v4.21.0) [Compare Source](https://github.com/aquaproj/aqua-registry/compare/v4.20.0...v4.21.0) [Issues](https://github.com/aquaproj/aqua-registry/issues?q=is%3Aissue+milestone%3Av4.21.0) | [Pull Requests](https://github.com/aquaproj/aqua-registry/pulls?q=is%3Apr+milestone%3Av4.21.0) | aquaproj/aqua-registry@v4.20.0...v4.21.0 #### 🎉 New Packages [#​13173](https://github.com/aquaproj/aqua-registry/issues/13173) [assetnote/surf](https://github.com/assetnote/surf): Escalate your SSRF vulnerabilities on Modern Cloud Environments. `surf` allows you to filter a list of hosts, returning a list of viable SSRF candidates [#​13174](https://github.com/aquaproj/aqua-registry/issues/13174) [iyear/tdl](https://github.com/iyear/tdl): A Telegram downloader written in Golang [#​13172](https://github.com/aquaproj/aqua-registry/issues/13172) [nikolaydubina/go-cover-treemap](https://github.com/nikolaydubina/go-cover-treemap): Go code coverage to SVG treemap [@​iwata](https://github.com/iwata) </details> <details> <summary>cli/cli</summary> ### [`v2.31.0`](https://github.com/cli/cli/releases/tag/v2.31.0): GitHub CLI 2.31.0 [Compare Source](https://github.com/cli/cli/compare/v2.30.0...v2.31.0) #### What's New - New suite of `project` commands for interacting with and manipulating projects. Huge shoutout 🥳 for the time and effort put into this work by [@​mntlty](https://github.com/mntlty) in [https://github.com/cli/cli/pull/7375](https://github.com/cli/cli/pull/7375) [https://github.com/cli/cli/pull/7578](https://github.com/cli/cli/pull/7578) - New `search code` command by [@​joshkraft](https://github.com/joshkraft) in [https://github.com/cli/cli/pull/7376](https://github.com/cli/cli/pull/7376) - New `cs view` command by [@​dmgardiner25](https://github.com/dmgardiner25) in [https://github.com/cli/cli/pull/7496](https://github.com/cli/cli/pull/7496) [https://github.com/cli/cli/pull/7539](https://github.com/cli/cli/pull/7539) #### What's Changed - `api`: output a single JSON array in REST pagination mode by [@​mislav](https://github.com/mislav) in [https://github.com/cli/cli/pull/7190](https://github.com/cli/cli/pull/7190) - `api`: support array params in GET queries by [@​mislav](https://github.com/mislav) in [https://github.com/cli/cli/pull/7513](https://github.com/cli/cli/pull/7513) - `api`: force method to uppercase by [@​ffalor](https://github.com/ffalor) in [https://github.com/cli/cli/pull/7514](https://github.com/cli/cli/pull/7514) - `alias`: Allow aliases to recognize extended commands by [@​srz-zumix](https://github.com/srz-zumix) in [https://github.com/cli/cli/pull/7523](https://github.com/cli/cli/pull/7523) - `alias import`: Fix `--clobber` flag by [@​samcoe](https://github.com/samcoe) in [https://github.com/cli/cli/pull/7569](https://github.com/cli/cli/pull/7569) - `run rerun`: Improve docs around `--job` flag by [@​williammartin](https://github.com/williammartin) in [https://github.com/cli/cli/pull/7527](https://github.com/cli/cli/pull/7527) - `run view`: Support viewing logs for jobs with composite actions by [@​williammartin](https://github.com/williammartin) in [https://github.com/cli/cli/pull/7526](https://github.com/cli/cli/pull/7526) - `gist edit`: Add selector option to `gist edit` command by [@​kousikmitra](https://github.com/kousikmitra) in [https://github.com/cli/cli/pull/7537](https://github.com/cli/cli/pull/7537) - `repo clone`: Set upstream remote to track all branches after initial fetch by [@​samcoe](https://github.com/samcoe) in [https://github.com/cli/cli/pull/7542](https://github.com/cli/cli/pull/7542) - `extension`: Speed up listing extensions by lazy-loading extension information when needed by [@​mislav](https://github.com/mislav) in [https://github.com/cli/cli/pull/7493](https://github.com/cli/cli/pull/7493) - `auth`: Add timeouts to keyring operations by [@​samcoe](https://github.com/samcoe) in [https://github.com/cli/cli/pull/7580](https://github.com/cli/cli/pull/7580) - `auth status`: write to stdout on success by [@​rajhawaldar](https://github.com/rajhawaldar) in [https://github.com/cli/cli/pull/7540](https://github.com/cli/cli/pull/7540) - `completion`: Fix bash completions for extensions and aliases by [@​mislav](https://github.com/mislav) in [https://github.com/cli/cli/pull/7525](https://github.com/cli/cli/pull/7525) - `issue/pr view`: alphabetically sort labels for `gh pr/issue view` by [@​ffalor](https://github.com/ffalor) in [https://github.com/cli/cli/pull/7587](https://github.com/cli/cli/pull/7587) - Fix error handling for extension and shell alias commands by [@​samcoe](https://github.com/samcoe) in [https://github.com/cli/cli/pull/7567](https://github.com/cli/cli/pull/7567) - Fix pkg imported more than once by [@​testwill](https://github.com/testwill) in [https://github.com/cli/cli/pull/7591](https://github.com/cli/cli/pull/7591) - Refactor a nested if statement by [@​yanskun](https://github.com/yanskun) in [https://github.com/cli/cli/pull/7596](https://github.com/cli/cli/pull/7596) - Fix a typo by [@​lerocknrolla](https://github.com/lerocknrolla) in [https://github.com/cli/cli/pull/7557](https://github.com/cli/cli/pull/7557) - Fix flaky test by [@​samcoe](https://github.com/samcoe) in [https://github.com/cli/cli/pull/7515](https://github.com/cli/cli/pull/7515) - Credential rotations, renames and decouplings from Mislav by [@​williammartin](https://github.com/williammartin) in [https://github.com/cli/cli/pull/7544](https://github.com/cli/cli/pull/7544) - build(deps): bump github.com/cli/go-gh/v2 from 2.0.0 to 2.0.1 by [@​dependabot](https://github.com/dependabot) in [https://github.com/cli/cli/pull/7546](https://github.com/cli/cli/pull/7546) - build(deps): bump github.com/AlecAivazis/survey/v2 from 2.3.6 to 2.3.7 by [@​dependabot](https://github.com/dependabot) in [https://github.com/cli/cli/pull/7576](https://github.com/cli/cli/pull/7576) #### New Contributors - [@​srz-zumix](https://github.com/srz-zumix) made their first contribution in [https://github.com/cli/cli/pull/7523](https://github.com/cli/cli/pull/7523) - [@​lerocknrolla](https://github.com/lerocknrolla) made their first contribution in [https://github.com/cli/cli/pull/7557](https://github.com/cli/cli/pull/7557) - [@​testwill](https://github.com/testwill) made their first contribution in [https://github.com/cli/cli/pull/7591](https://github.com/cli/cli/pull/7591) - [@​rajhawaldar](https://github.com/rajhawaldar) made their first contribution in [https://github.com/cli/cli/pull/7540](https://github.com/cli/cli/pull/7540) **Full Changelog**: cli/cli@v2.30.0...v2.31.0 </details> <details> <summary>weaveworks/eksctl</summary> ### [`v0.146.0`](https://github.com/weaveworks/eksctl/releases/tag/v0.146.0): eksctl 0.146.0 (permalink) [Compare Source](https://github.com/weaveworks/eksctl/compare/0.145.0...0.146.0) ### Release v0.146.0 #### 🎯 Improvements - Update vpc-cni to 1.12.6 ([#​6692](https://github.com/weaveworks/eksctl/issues/6692)) #### 🧰 Maintenance - Bump dependencies ([#​6690](https://github.com/weaveworks/eksctl/issues/6690)) #### 📝 Documentation - New eksctl channel ([#​6697](https://github.com/weaveworks/eksctl/issues/6697)) #### Acknowledgments Weaveworks would like to sincerely thank: [@​wind0r](https://github.com/wind0r) </details> <details> <summary>zellij-org/zellij</summary> ### [`v0.37.2`](https://github.com/zellij-org/zellij/releases/tag/v0.37.2) [Compare Source](https://github.com/zellij-org/zellij/compare/v0.37.1...v0.37.2) This is a patch release to fix some minor issues in the previous release. #### What's Changed - hotfix: include theme files into binary by [@​jaeheonji](https://github.com/jaeheonji) in [https://github.com/zellij-org/zellij/pull/2566](https://github.com/zellij-org/zellij/pull/2566) - fix(plugins): make hide_self api idempotent by [@​imsnif](https://github.com/imsnif) in [https://github.com/zellij-org/zellij/pull/2568](https://github.com/zellij-org/zellij/pull/2568) **Full Changelog**: zellij-org/zellij@v0.37.1...v0.37.2 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/scottames/dots). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xMzEuMCIsInVwZGF0ZWRJblZlciI6IjM1LjEzMS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
After running
repo clone
set the upstream remote to track all branches instead of just the default branch.This PR also adds a
Copy()
method to the git client as that pattern had been used a couple of times across the codebase.Fixes #5385