Fix browse issue with leading hashtag (#6144)
This commit is contained in:
parent
2fc0ffd0be
commit
ac036c1c5b
2 changed files with 10 additions and 2 deletions
|
|
@ -167,7 +167,7 @@ func parseSection(baseRepo ghrepo.Interface, opts *BrowseOptions) (string, error
|
|||
}
|
||||
|
||||
if isNumber(opts.SelectorArg) {
|
||||
return fmt.Sprintf("issues/%s", opts.SelectorArg), nil
|
||||
return fmt.Sprintf("issues/%s", strings.TrimPrefix(opts.SelectorArg, "#")), nil
|
||||
}
|
||||
|
||||
if isCommit(opts.SelectorArg) {
|
||||
|
|
@ -253,7 +253,7 @@ func parseFile(opts BrowseOptions, f string) (p string, start int, end int, err
|
|||
}
|
||||
|
||||
func isNumber(arg string) bool {
|
||||
_, err := strconv.Atoi(arg)
|
||||
_, err := strconv.Atoi(strings.TrimPrefix(arg, "#"))
|
||||
return err == nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -222,6 +222,14 @@ func Test_runBrowse(t *testing.T) {
|
|||
baseRepo: ghrepo.New("kevin", "MinTy"),
|
||||
expectedURL: "https://github.com/kevin/MinTy/issues/217",
|
||||
},
|
||||
{
|
||||
name: "issue with hashtag argument",
|
||||
opts: BrowseOptions{
|
||||
SelectorArg: "#217",
|
||||
},
|
||||
baseRepo: ghrepo.New("kevin", "MinTy"),
|
||||
expectedURL: "https://github.com/kevin/MinTy/issues/217",
|
||||
},
|
||||
{
|
||||
name: "branch flag",
|
||||
opts: BrowseOptions{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue