From d1bb30887584a195327d5ff576c316760c093ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Tue, 10 Nov 2020 13:18:59 +0100 Subject: [PATCH 1/2] Replace references to "master" branch with "main" --- commands/browse.go | 12 ++++++------ commands/compare.go | 6 +++--- commands/merge.go | 2 +- commands/pull_request.go | 6 +++--- github/branch.go | 6 +++--- github/localrepo.go | 2 +- share/man/man1/hub.1.md | 3 +-- 7 files changed, 18 insertions(+), 19 deletions(-) diff --git a/commands/browse.go b/commands/browse.go index 7f1ce2775..b292b22c6 100644 --- a/commands/browse.go +++ b/commands/browse.go @@ -76,15 +76,15 @@ func browse(command *Command, args *Args) { localRepo, _ := github.LocalRepo() if dest != "" { project = github.NewProject("", dest, "") - branch = localRepo.MasterBranch() + branch = localRepo.MainBranch() } else if subpage != "" && subpage != "commits" && subpage != "tree" && subpage != "blob" && subpage != "settings" { project, err = localRepo.MainProject() - branch = localRepo.MasterBranch() + branch = localRepo.MainBranch() utils.Check(err) } else { currentBranch, err := localRepo.CurrentBranch() if err != nil { - currentBranch = localRepo.MasterBranch() + currentBranch = localRepo.MainBranch() } var owner string @@ -98,9 +98,9 @@ func browse(command *Command, args *Args) { } } - branch, project, _ = localRepo.RemoteBranchAndProject(owner, currentBranch.IsMaster()) + branch, project, _ = localRepo.RemoteBranchAndProject(owner, currentBranch.IsMain()) if branch == nil { - branch = localRepo.MasterBranch() + branch = localRepo.MainBranch() } } @@ -111,7 +111,7 @@ func browse(command *Command, args *Args) { if subpage == "commits" { path = fmt.Sprintf("commits/%s", branchInURL(branch)) } else if subpage == "tree" || subpage == "" { - if !branch.IsMaster() { + if !branch.IsMain() { path = fmt.Sprintf("tree/%s", branchInURL(branch)) } } else { diff --git a/commands/compare.go b/commands/compare.go index 6bba2c729..80f099b12 100644 --- a/commands/compare.go +++ b/commands/compare.go @@ -33,7 +33,7 @@ compare [-uc] [] [...] If a range with two dots (''A..B'') is given, it will be transformed into a range with three dots. - The portion defaults to the default branch of the repository. + The portion defaults to the main branch of the repository. The argument defaults to the current branch. If the current branch is not pushed to a remote, the command will error. @@ -97,8 +97,8 @@ func compare(command *Command, args *Args) { r = remoteBranch.ShortName() if remoteProject.SameAs(mainProject) { - if flagCompareBase == "" && remoteBranch.IsMaster() { - utils.Check(fmt.Errorf("the branch to compare '%s' is the default branch", remoteBranch.ShortName())) + if flagCompareBase == "" && remoteBranch.IsMain() { + utils.Check(fmt.Errorf("the branch to compare '%s' is the main branch", remoteBranch.ShortName())) } } else { r = fmt.Sprintf("%s:%s", remoteProject.Owner, r) diff --git a/commands/merge.go b/commands/merge.go index f20ac83f0..4e1d46a06 100644 --- a/commands/merge.go +++ b/commands/merge.go @@ -17,7 +17,7 @@ var cmdMerge = &Command{ This creates a local merge commit in the current branch, but does not actually change the state of the pull request. However, the pull request will get auto-closed and marked as "merged" as soon as the newly created merge commit is -pushed to the default branch of the remote repository. +pushed to the main branch of the remote repository. To merge a pull request remotely, use ''hub pr merge''. diff --git a/commands/pull_request.go b/commands/pull_request.go index 1472b1d96..423668b34 100644 --- a/commands/pull_request.go +++ b/commands/pull_request.go @@ -68,8 +68,8 @@ pull-request -i Push the current branch to before creating the pull request. -b, --base - The base branch in the "[:]" format. Defaults to the default - branch of the upstream repository (usually "master"). + The base branch in the "[:]" format. Defaults to the main + branch of the upstream repository. See the "CONVENTIONS" section of hub(1) for more information on how hub selects the defaults in case of multiple git remotes. @@ -107,7 +107,7 @@ pull-request -i [ opens a text editor for writing title and message ] [ creates a pull request for the current branch ] - $ hub pull-request --base OWNER:master --head MYUSER:my-branch + $ hub pull-request --base OWNER:main --head MYUSER:my-branch [ creates a pull request with explicit base and head branches ] $ hub pull-request --browse -m "My title" diff --git a/github/branch.go b/github/branch.go index 2466dbea9..78f222c2b 100644 --- a/github/branch.go +++ b/github/branch.go @@ -43,9 +43,9 @@ func (b *Branch) Upstream() (u *Branch, err error) { return } -func (b *Branch) IsMaster() bool { - masterName := b.Repo.MasterBranch().ShortName() - return b.ShortName() == masterName +func (b *Branch) IsMain() bool { + mainName := b.Repo.MainBranch().ShortName() + return b.ShortName() == mainName } func (b *Branch) IsRemote() bool { diff --git a/github/localrepo.go b/github/localrepo.go index dc04c3471..941c91a27 100644 --- a/github/localrepo.go +++ b/github/localrepo.go @@ -104,7 +104,7 @@ func (r *GitHubRepo) CurrentBranch() (branch *Branch, err error) { return } -func (r *GitHubRepo) MasterBranch() *Branch { +func (r *GitHubRepo) MainBranch() *Branch { if remote, err := r.MainRemote(); err == nil { return r.DefaultBranch(remote) } diff --git a/share/man/man1/hub.1.md b/share/man/man1/hub.1.md index 1fd3cc9f2..3a3c4db45 100644 --- a/share/man/man1/hub.1.md +++ b/share/man/man1/hub.1.md @@ -110,8 +110,7 @@ When working with forks, it's recommended that the git remote for your own fork is named "origin" and that the git remote for the upstream repository is named "upstream". See -The default branch (usually "master") for the current repository is detected -like so: +The main branch for the current repository is detected like so: git symbolic-ref refs/remotes/origin/HEAD From 673fe34d1e2796a769e39dcba968f3112885c98f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Mon, 4 Apr 2022 14:30:28 +0200 Subject: [PATCH 2/2] Fix test --- features/compare.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/compare.feature b/features/compare.feature index cef62369c..69f43a6ff 100644 --- a/features/compare.feature +++ b/features/compare.feature @@ -28,7 +28,7 @@ Feature: hub compare And I am on the "develop" branch with upstream "origin/develop" When I run `hub compare` Then the exit status should be 1 - And the stderr should contain exactly "the branch to compare 'develop' is the default branch\n" + And the stderr should contain exactly "the branch to compare 'develop' is the main branch\n" Scenario: No args, has upstream branch Given I am on the "feature" branch with upstream "origin/experimental"