git: Factorize 'resolve-reference'.
* guix/git.scm (resolve-reference): New procedure. (switch-to-ref): Use it.
This commit is contained in:
parent
9e0d896bf3
commit
1c058c382a
1 changed files with 42 additions and 37 deletions
13
guix/git.scm
13
guix/git.scm
|
|
@ -150,10 +150,9 @@ of SHA1 string."
|
||||||
(last (string-split url #\/)) ".git" "")
|
(last (string-split url #\/)) ".git" "")
|
||||||
"-" (string-take sha1 7)))
|
"-" (string-take sha1 7)))
|
||||||
|
|
||||||
(define (switch-to-ref repository ref)
|
(define (resolve-reference repository ref)
|
||||||
"Switch to REPOSITORY's branch, commit or tag specified by REF. Return the
|
"Resolve the branch, commit or tag specified by REF, and return the
|
||||||
OID (roughly the commit hash) corresponding to REF."
|
corresponding Git object."
|
||||||
(define obj
|
|
||||||
(let resolve ((ref ref))
|
(let resolve ((ref ref))
|
||||||
(match ref
|
(match ref
|
||||||
(('branch . branch)
|
(('branch . branch)
|
||||||
|
|
@ -192,6 +191,12 @@ OID (roughly the commit hash) corresponding to REF."
|
||||||
;; object, whatever that is.
|
;; object, whatever that is.
|
||||||
(object-lookup repository oid))))))
|
(object-lookup repository oid))))))
|
||||||
|
|
||||||
|
(define (switch-to-ref repository ref)
|
||||||
|
"Switch to REPOSITORY's branch, commit or tag specified by REF. Return the
|
||||||
|
OID (roughly the commit hash) corresponding to REF."
|
||||||
|
(define obj
|
||||||
|
(resolve-reference repository ref))
|
||||||
|
|
||||||
(reset repository obj RESET_HARD)
|
(reset repository obj RESET_HARD)
|
||||||
(object-id obj))
|
(object-id obj))
|
||||||
|
|
||||||
|
|
|
||||||
Reference in a new issue