@@ -141,9 +141,9 @@ type SymbolicRefOptions struct {
141141}
142142
143143// 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 ) {
147147 var opt SymbolicRefOptions
148148 if len (opts ) > 0 {
149149 opt = opts [0 ]
@@ -158,13 +158,20 @@ func (r *Repository) SymbolicRef(opts ...SymbolicRefOptions) (string, error) {
158158 cmd .AddArgs (opt .Ref )
159159 }
160160
161- stdout , err := cmd .RunInDirWithTimeout (opt .Timeout , r . path )
161+ stdout , err := cmd .RunInDirWithTimeout (opt .Timeout , repoPath )
162162 if err != nil {
163163 return "" , err
164164 }
165165 return strings .TrimSpace (string (stdout )), nil
166166}
167167
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+
168175// ShowRefOptions contains optional arguments for listing references.
169176//
170177// Docs: https://git-scm.com/docs/git-show-ref
0 commit comments