@@ -141,9 +141,9 @@ type SymbolicRefOptions struct {
141
141
}
142
142
143
143
// SymbolicRef returns the reference name (e.g. "refs/heads/master") pointed by
144
- // the symbolic ref. It returns an empty string and nil error when doing set
145
- // operation.
146
- func ( r * Repository ) SymbolicRef ( opts ... SymbolicRefOptions ) (string , error ) {
144
+ // the symbolic ref in the repository in given path. It returns an empty string
145
+ // and nil error when doing set operation.
146
+ func SymbolicRef ( repoPath string , opts ... SymbolicRefOptions ) (string , error ) {
147
147
var opt SymbolicRefOptions
148
148
if len (opts ) > 0 {
149
149
opt = opts [0 ]
@@ -158,13 +158,20 @@ func (r *Repository) SymbolicRef(opts ...SymbolicRefOptions) (string, error) {
158
158
cmd .AddArgs (opt .Ref )
159
159
}
160
160
161
- stdout , err := cmd .RunInDirWithTimeout (opt .Timeout , r . path )
161
+ stdout , err := cmd .RunInDirWithTimeout (opt .Timeout , repoPath )
162
162
if err != nil {
163
163
return "" , err
164
164
}
165
165
return strings .TrimSpace (string (stdout )), nil
166
166
}
167
167
168
+ // SymbolicRef returns the reference name (e.g. "refs/heads/master") pointed by
169
+ // the symbolic ref. It returns an empty string and nil error when doing set
170
+ // operation.
171
+ func (r * Repository ) SymbolicRef (opts ... SymbolicRefOptions ) (string , error ) {
172
+ return SymbolicRef (r .path , opts ... )
173
+ }
174
+
168
175
// ShowRefOptions contains optional arguments for listing references.
169
176
//
170
177
// Docs: https://git-scm.com/docs/git-show-ref
0 commit comments