Merge pull request #7038 from yanskun/feat/add-open-num-commit-hash
Made it possible to do open num only commit hash with Browse Command
This commit is contained in:
commit
fe78331342
2 changed files with 21 additions and 1 deletions
|
|
@ -174,7 +174,7 @@ func parseSection(baseRepo ghrepo.Interface, opts *BrowseOptions) (string, error
|
|||
}
|
||||
}
|
||||
|
||||
if isNumber(opts.SelectorArg) {
|
||||
if !opts.CommitFlag && isNumber(opts.SelectorArg) {
|
||||
return fmt.Sprintf("issues/%s", strings.TrimPrefix(opts.SelectorArg, "#")), nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -123,6 +123,15 @@ func TestNewCmdBrowse(t *testing.T) {
|
|||
},
|
||||
wantsErr: false,
|
||||
},
|
||||
{
|
||||
name: "commit hash flag",
|
||||
cli: "-c 123",
|
||||
wants: BrowseOptions{
|
||||
CommitFlag: true,
|
||||
SelectorArg: "123",
|
||||
},
|
||||
wantsErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
|
@ -395,6 +404,17 @@ func Test_runBrowse(t *testing.T) {
|
|||
wantsErr: false,
|
||||
expectedURL: "https://github.com/vilmibm/gh-user-status/tree/6f1a2405cace1633d89a79c74c65f22fe78f9659/main.go",
|
||||
},
|
||||
{
|
||||
name: "open number only commit hash",
|
||||
opts: BrowseOptions{
|
||||
CommitFlag: true,
|
||||
SelectorArg: "1234567890",
|
||||
GitClient: &testGitClient{},
|
||||
},
|
||||
baseRepo: ghrepo.New("yanskun", "ILoveGitHub"),
|
||||
wantsErr: false,
|
||||
expectedURL: "https://github.com/yanskun/ILoveGitHub/commit/1234567890",
|
||||
},
|
||||
{
|
||||
name: "relative path from browse_test.go",
|
||||
opts: BrowseOptions{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue