Ce serveur Gitlab sera éteint le 30 juin 2020, pensez à migrer vos projets vers les serveurs gitlab-research.centralesupelec.fr et gitlab-student.centralesupelec.fr !

Commit f7d75165 authored by Ryan Thompson's avatar Ryan Thompson

Merge pull request #506 from DarwinAwardWinner/git-checkout-property

Implement ":checkout" property for git recipes
parents 8befd64d a30a6c50
......@@ -313,7 +313,14 @@ properties:
`process-send-string' for an asynchronous one.
Any other property will get put into the process object.
Any element of commands that is nil will simply be ignored. This
makes it easier to conditionally splice a command into the list.
"
;; Skip nil elements of commands. This makes it easier for methods
;; to conditionally splice commands into the list.
(while (and commands (null (car commands)))
(setq commands (cdr commands)))
(condition-case err
(if commands
(let* ((c (car commands))
......
......@@ -284,6 +284,22 @@ definition provided by `el-get' recipes locally.
with the following meaning:
* `http', `ftp' and `emacswiki' with the SHA1 of the downloaded file
* `git' in which it is an alias for `:checkout' (see below)
:checkout
A git refspec (branch, tag, commit hash) that should be
checked out after cloning the git repository. If provided,
this overrides any value for the `:branch' property. Unlike
the `:branch' property, this can be any valid argument to
`git checkout', including a tag name or a commit hash. The
intended use of this property is to \"lock\" a repository at
a particular revision, regardless of what happens to the repo
upstream.
Currently this property only has meaning for `git' type
recipes. Other VCS-based methods may implement support in the
future.
"
:group 'el-get
:type
......
......@@ -47,6 +47,7 @@
;; - add support for el-get-reload and do that at update time
;; - implement :checksum property for http kinds of files
;; - Add new command el-get-reinstall
;; - implement :checkout property for git packages
;;
;; 3.1 - 2011-09-15 - Get a fix
;;
......
......@@ -40,9 +40,19 @@ found."
(name (format "*git clone %s*" package))
(source (el-get-package-def package))
(branch (plist-get source :branch))
(args (if branch
(list "--no-pager" "clone" "-b" branch url pname)
(list "--no-pager" "clone" url pname)))
(checkout (or (plist-get source :checkout)
(plist-get source :checksum)))
(clone-args (append '("--no-pager" "clone")
(cond
;; With :checkout, the "git checkout"
;; command is a separate step, so don't
;; do it during cloning.
(checkout '("--no-checkout"))
;; With a specified branch, check that branch out
(branch (list "-b" branch))
;; Otherwise, just checkout the default branch
(t nil))
(list url pname)))
(ok (format "Package %s installed." package))
(ko (format "Could not install package %s." package)))
(el-get-start-process-list
......@@ -51,9 +61,17 @@ found."
:buffer-name ,name
:default-directory ,el-get-dir
:program ,git-executable
:args ,args
:args ,clone-args
:message ,ok
:error ,ko)
,(when checkout
(list :command-name (format "*git checkout %s*" checkout)
:buffer-name name
:default-directory pdir
:program git-executable
:args (list "--no-pager" "checkout" checkout)
:message (format "git checkout %s ok" checkout)
:error (format "Could not checkout %s for package %s" checkout package)))
(:command-name "*git submodule update*"
:buffer-name ,name
:default-directory ,pdir
......@@ -68,18 +86,31 @@ found."
(let* ((git-executable (el-get-executable-find "git"))
(pdir (el-get-package-directory package))
(name (format "*git pull %s*" package))
(source (el-get-package-def package))
(checkout (or (plist-get source :checkout)
(plist-get source :checksum)))
;; When dealing with a specific checkout, we cannot use
;; "pull", but must instead use "fetch" and then "checkout".
(pull-args (list "--no-pager" (if checkout "fetch" "pull")))
(ok (format "Pulled package %s." package))
(ko (format "Could not update package %s." package)))
(el-get-start-process-list
package
`((:command-name ,name
:buffer-name ,name
:default-directory ,pdir
:program ,git-executable
:args ( "--no-pager" "pull")
:args ,pull-args
:message ,ok
:error ,ko)
,(when checkout
(list :command-name (format "*git checkout %s*" checkout)
:buffer-name name
:default-directory pdir
:program git-executable
:args (list "--no-pager" "checkout" checkout)
:message (format "git checkout %s ok" checkout)
:error (format "Could not checkout %s for package %s" checkout package)))
(:command-name "*git submodule update*"
:buffer-name ,name
:default-directory ,pdir
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment