Skip to content

Commit 158a151

Browse files
committed
Changed name from SHA to Commit
1 parent 0e18db2 commit 158a151

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

pkg/cmd/browse/browse.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type BrowseOptions struct {
2727
SelectorArg string
2828

2929
Branch string
30-
SHA string
30+
Commit string
3131
ProjectsFlag bool
3232
SettingsFlag bool
3333
WikiFlag bool
@@ -81,8 +81,9 @@ func NewCmdBrowse(f *cmdutil.Factory, runF func(*BrowseOptions) error) *cobra.Co
8181
}
8282

8383
if err := cmdutil.MutuallyExclusive(
84-
"specify only one of `--branch`, `--projects`, `--wiki`, or `--settings`",
84+
"specify only one of `--branch`, `--commit`, `--projects`, `--wiki`, or `--settings`",
8585
opts.Branch != "",
86+
opts.Commit != "",
8687
opts.WikiFlag,
8788
opts.SettingsFlag,
8889
opts.ProjectsFlag,
@@ -103,7 +104,7 @@ func NewCmdBrowse(f *cmdutil.Factory, runF func(*BrowseOptions) error) *cobra.Co
103104
cmd.Flags().BoolVarP(&opts.SettingsFlag, "settings", "s", false, "Open repository settings")
104105
cmd.Flags().BoolVarP(&opts.NoBrowserFlag, "no-browser", "n", false, "Print destination URL instead of opening the browser")
105106
cmd.Flags().StringVarP(&opts.Branch, "branch", "b", "", "Select another branch by passing in the branch name")
106-
cmd.Flags().StringVarP(&opts.SHA, "sha", "a", "", "Select a commit by passing in the SHA hash")
107+
cmd.Flags().StringVarP(&opts.Commit, "commit", "c", "", "Select a commit by passing in the SHA hash")
107108

108109
return cmd
109110
}
@@ -129,8 +130,8 @@ func runBrowse(opts *BrowseOptions) error {
129130
url += "/wiki"
130131
} else if opts.Branch != "" {
131132
url += "/tree/" + opts.Branch + "/"
132-
} else if opts.SHA != "" {
133-
url += "/tree/" + opts.SHA + "/"
133+
} else if opts.Commit != "" {
134+
url += "/tree/" + opts.Commit + "/"
134135
}
135136
} else {
136137
if isNumber(opts.SelectorArg) {
@@ -142,8 +143,8 @@ func runBrowse(opts *BrowseOptions) error {
142143
}
143144
if opts.Branch != "" {
144145
url += "/tree/" + opts.Branch + "/"
145-
} else if opts.SHA != "" {
146-
url += "/tree/" + opts.SHA + "/"
146+
} else if opts.Commit != "" {
147+
url += "/tree/" + opts.Commit + "/"
147148
} else {
148149
apiClient := api.NewClientFromHTTP(httpClient)
149150
branchName, err := api.RepoDefaultBranch(apiClient, baseRepo)

pkg/cmd/browse/browse_test.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,21 @@ func TestNewCmdBrowse(t *testing.T) {
5959
wantsErr: false,
6060
},
6161
{
62-
name: "SHA flag",
63-
cli: "--sha e32e640",
62+
name: "Commit flag",
63+
cli: "--commit e32e640",
6464
wants: BrowseOptions{
65-
SHA: "e32e640",
65+
Commit: "e32e640",
6666
},
6767
wantsErr: false,
6868
},
6969
{
70-
name: "SHA flag no arg",
71-
cli: "-a",
70+
name: "Commit flag no arg",
71+
cli: "-c",
72+
wantsErr: true,
73+
},
74+
{
75+
name: "Multi flags",
76+
cli: "-c 1a2b3c -b trunk",
7277
wantsErr: true,
7378
},
7479
{
@@ -268,18 +273,18 @@ func Test_runBrowse(t *testing.T) {
268273
expectedURL: "https://github.com/mislav/will_paginate/tree/3-0-stable/init.rb#L6",
269274
},
270275
{
271-
name: "opening browser with SHA hash no args",
276+
name: "opening browser with Commit hash no args",
272277
opts: BrowseOptions{
273-
SHA: "162a1b2",
278+
Commit: "162a1b2",
274279
},
275280
baseRepo: ghrepo.New("torvalds", "linux"),
276281
wantsErr: false,
277282
expectedURL: "https://github.com/torvalds/linux/tree/162a1b2/",
278283
},
279284
{
280-
name: "opening browser with SHA hash file arg",
285+
name: "opening browser with commit hash file arg",
281286
opts: BrowseOptions{
282-
SHA: "162a1b2",
287+
Commit: "162a1b2",
283288
SelectorArg: "api/cache.go:32",
284289
},
285290
baseRepo: ghrepo.New("cli", "cli"),

0 commit comments

Comments
 (0)