Skip to content

Commit 679d396

Browse files
committed
reformatted spacing and final touches
1 parent cac372d commit 679d396

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

pkg/cmd/browse/browse.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ func NewCmdBrowse(f *cmdutil.Factory, runF func(*BrowseOptions) error) *cobra.Co
105105
}
106106

107107
func runBrowse(opts *BrowseOptions) error {
108-
109108
baseRepo, err := opts.BaseRepo()
110109
if err != nil {
111110
return fmt.Errorf("unable to determine base repository: %w\nUse 'gh browse --help' for more information about browse\n", err)
@@ -115,19 +114,15 @@ func runBrowse(opts *BrowseOptions) error {
115114
if err != nil {
116115
return fmt.Errorf("unable to create an http client: %w\nUse 'gh browse --help' for more information about browse\n", err)
117116
}
118-
119117
url := ghrepo.GenerateRepoURL(baseRepo, "")
120118

121119
if opts.SelectorArg == "" {
122-
123120
if opts.ProjectsFlag {
124121
url += "/projects"
125122
}
126-
127123
if opts.SettingsFlag {
128124
url += "/settings"
129125
}
130-
131126
if opts.WikiFlag {
132127
url += "/wiki"
133128
}
@@ -161,13 +156,15 @@ func runBrowse(opts *BrowseOptions) error {
161156
}
162157
}
163158
}
159+
164160
err = opts.Browser.Browse(url)
165161
if opts.IO.IsStdoutTTY() && err == nil {
166162
fmt.Fprintf(opts.IO.Out, "now opening %s in browser\n", url)
167163
}
168164

169165
return err
170166
}
167+
171168
func parseFileArg(fileArg string) ([]string, error) {
172169
arr := strings.Split(fileArg, ":")
173170
if len(arr) > 2 {
@@ -176,7 +173,6 @@ func parseFileArg(fileArg string) ([]string, error) {
176173
if len(arr) > 1 && !isNumber(arr[1]) {
177174
return arr, fmt.Errorf("invalid line number after colon\nUse 'gh browse --help' for more information about browse\n")
178175
}
179-
180176
return arr, nil
181177
}
182178

pkg/cmd/browse/browse_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ func Test_runBrowse(t *testing.T) {
185185
opts: BrowseOptions{
186186
Branch: "trunk",
187187
},
188-
baseRepo: ghrepo.New("jlsestak", "vegan"),
189-
expectedURL: "https://github.com/jlsestak/vegan/tree/trunk/",
188+
baseRepo: ghrepo.New("jlsestak", "CouldNotThinkOfARepoName"),
189+
expectedURL: "https://github.com/jlsestak/CouldNotThinkOfARepoName/tree/trunk/",
190190
},
191191
{
192192
name: "branch flag with file",
@@ -225,13 +225,14 @@ func Test_runBrowse(t *testing.T) {
225225
expectedURL: "https://github.com/ken/grc/issues/217",
226226
},
227227
{
228-
name: "opening branch",
228+
name: "opening branch file with line number",
229229
opts: BrowseOptions{
230-
Branch: "first-browse-pull",
230+
Branch: "first-browse-pull",
231+
SelectorArg: "browse.go:32",
231232
},
232233
baseRepo: ghrepo.New("github", "ThankYouGitHub"),
233234
wantsErr: false,
234-
expectedURL: "https://github.com/github/ThankYouGitHub/tree/first-browse-pull/",
235+
expectedURL: "https://github.com/github/ThankYouGitHub/tree/first-browse-pull/browse.go#L32",
235236
},
236237
}
237238

0 commit comments

Comments
 (0)