Add checksum methods for git and hg.

These return the hash of the current revision of the package
This commit is contained in:
Ryan C. Thompson 2012-02-01 16:10:52 -08:00
parent dc22e60e6e
commit 0e908c8100
2 changed files with 24 additions and 2 deletions

View File

@ -89,8 +89,19 @@ found."
:error "Could not update git submodules"))
post-update-fun)))
(defun el-get-git-compute-checksum (package)
"Return the hash of the checked-out revision of PACKAGE."
(with-temp-buffer
(cd (el-get-package-directory package))
(let* ((args '("git" "show-ref" "HEAD"))
(cmd (mapconcat 'shell-quote-argument args " "))
(output (shell-command-to-string cmd))
(hash (and (string-match "^[[:space:]]*\\([^[:space:]]+\\)" output)
(match-string 0 output))))
hash)))
(el-get-register-method
:git #'el-get-git-clone #'el-get-git-pull #'el-get-rmdir
#'el-get-git-clone-hook)
#'el-get-git-clone-hook nil #'el-get-git-compute-checksum)
(provide 'el-get-git)

View File

@ -58,8 +58,19 @@
:error ,ko))
post-update-fun)))
(defun el-get-hg-compute-checksum (package)
"Return the hash of the checked-out revision of PACKAGE."
(with-temp-buffer
(cd (el-get-package-directory package))
(let* ((args '("hg" "--debug" "tags"))
(cmd (mapconcat 'shell-quote-argument args " "))
(output (shell-command-to-string cmd))
(hash (and (string-match "^tip[[:space:]]+[0-9]+\\:\\([0-9A-Fa-f]+\\)" output)
(match-string 0 output))))
hash)))
(el-get-register-method
:hg #'el-get-hg-clone #'el-get-hg-pull #'el-get-rmdir
#'el-get-hg-clone-hook)
#'el-get-hg-clone-hook nil #'el-get-hg-compute-checksum)
(provide 'el-get-hg)