diff options
| author | Shulhan <m.shulhan@gmail.com> | 2024-07-21 03:48:32 +0700 |
|---|---|---|
| committer | Shulhan <m.shulhan@gmail.com> | 2026-04-09 22:20:06 +0700 |
| commit | 31f678e5a420fecf567c30bc66e40b43ad85fd17 (patch) | |
| tree | e3b1a4b83fb4db9e2dde3d3846966240e3b5e618 /git-codereview/pending.go | |
| parent | 99962d5770bded6aa8fac22d4c74103b5f832d6d (diff) | |
| download | go-x-review-main.tar.xz | |
For the git-codereview commands to works on any Go's repositories, the
remote name for "origin" must be pointed to the Go original repository URL
(in most cases the one with go.googlesource.com domain).
The problem is when the "origin" is from the fork, all of the
git-codereview commands then will not works.
For example, in computer X, I clone the this repository from
"https://go.googlesource.com/review" (the origin) and then push my
changes on "git@git.sr.ht:~shulhan/go-x-review" (the fork).
In another computer Y, I then clone from the fork to continue my works.
The fork become origin.
One of the solution is to rename the remote names manually each time we
clone the fork.
The only cons using this solution is every time new branch created we need
to remember to pass "--set-upstream" during git push.
This changes introduce "remote" configuration in codereview.cfg.
When one first working on fork of Go repository, they set the "remote"
key, commit it, and push it.
When they cloned the fork, they did not needs to changes anything except
adding new remote using the pre-defined name.
Change-Id: I335d08fd8b7efe17ba07b3c0a3794f9ccf59b339
Diffstat (limited to 'git-codereview/pending.go')
| -rw-r--r-- | git-codereview/pending.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/git-codereview/pending.go b/git-codereview/pending.go index 8a74e09..d03b003 100644 --- a/git-codereview/pending.go +++ b/git-codereview/pending.go @@ -240,6 +240,8 @@ func printPendingStandard(branches []*pendingBranch) { } } + cfgRemote := config()["remote"] + for _, b := range branches { if !b.current && b.commitsAhead == 0 { // Hide branches with no work on them. @@ -268,8 +270,8 @@ func printPendingStandard(branches []*pendingBranch) { } if br := b.OriginBranch(); br == "" { tags = append(tags, "remote branch unknown") - } else if br != "origin/master" && br != "origin/main" { - tags = append(tags, "tracking "+strings.TrimPrefix(b.OriginBranch(), "origin/")) + } else if br != cfgRemote+"/master" && br != cfgRemote+"/main" { + tags = append(tags, "tracking "+strings.TrimPrefix(b.OriginBranch(), cfgRemote+"/")) } if len(tags) > 0 { fmt.Fprintf(&buf, " (%s)", strings.Join(tags, ", ")) |
