@@ -27,6 +27,7 @@ type BrowseOptions struct {
2727 SelectorArg string
2828
2929 Branch string
30+ SHA string
3031 ProjectsFlag bool
3132 SettingsFlag bool
3233 WikiFlag bool
@@ -102,6 +103,7 @@ func NewCmdBrowse(f *cmdutil.Factory, runF func(*BrowseOptions) error) *cobra.Co
102103 cmd .Flags ().BoolVarP (& opts .SettingsFlag , "settings" , "s" , false , "Open repository settings" )
103104 cmd .Flags ().BoolVarP (& opts .NoBrowserFlag , "no-browser" , "n" , false , "Print destination URL instead of opening the browser" )
104105 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" )
105107
106108 return cmd
107109}
@@ -121,15 +123,14 @@ func runBrowse(opts *BrowseOptions) error {
121123 if opts .SelectorArg == "" {
122124 if opts .ProjectsFlag {
123125 url += "/projects"
124- }
125- if opts .SettingsFlag {
126+ } else if opts .SettingsFlag {
126127 url += "/settings"
127- }
128- if opts .WikiFlag {
128+ } else if opts .WikiFlag {
129129 url += "/wiki"
130- }
131- if opts .Branch != "" {
130+ } else if opts .Branch != "" {
132131 url += "/tree/" + opts .Branch + "/"
132+ } else if opts .SHA != "" {
133+ url += "/tree/" + opts .SHA + "/"
133134 }
134135 } else {
135136 if isNumber (opts .SelectorArg ) {
@@ -141,6 +142,8 @@ func runBrowse(opts *BrowseOptions) error {
141142 }
142143 if opts .Branch != "" {
143144 url += "/tree/" + opts .Branch + "/"
145+ } else if opts .SHA != "" {
146+ url += "/tree/" + opts .SHA + "/"
144147 } else {
145148 apiClient := api .NewClientFromHTTP (httpClient )
146149 branchName , err := api .RepoDefaultBranch (apiClient , baseRepo )
0 commit comments