diff mbox series

[bug#66171] gnu: git: Install shell completions.

Message ID e5452a70381443c07400cabf7f8c098cdb9849bf.1695498272.git.liliana.prikler@gmail.com
State New
Headers show
Series [bug#66171] gnu: git: Install shell completions. | expand

Commit Message

Liliana Marie Prikler Sept. 23, 2023, 7:43 p.m. UTC
* gnu/packages/version-control.scm (git)[outputs]: Add “completion”.
[#:phases]: Add ‘install-completion’.
---
 gnu/packages/version-control.scm | 15 +++++++++++++++
 1 file changed, 15 insertions(+)


base-commit: 4f35ff1275e05be31f5d41464ccf147e9dbfd016
prerequisite-patch-id: ee5d7299c5790d77e0d409f34165063fcff10a8b

Comments

Simon Tournier Sept. 25, 2023, 11:12 a.m. UTC | #1
Hi,

On Sat, 23 Sep 2023 at 21:43, Liliana Marie Prikler <liliana.prikler@gmail.com> wrote:
> * gnu/packages/version-control.scm (git)[outputs]: Add “completion”.
> [#:phases]: Add ‘install-completion’.

Naive question: this also adds “completion” to git-minimal, no?  I mean,
does the phase need to be deleted in git-minimal?

Cheers,
simon
diff mbox series

Patch

diff --git a/gnu/packages/version-control.scm b/gnu/packages/version-control.scm
index 9716a6f27a..54b2ed74fb 100644
--- a/gnu/packages/version-control.scm
+++ b/gnu/packages/version-control.scm
@@ -303,6 +303,7 @@  (define-public git
                "credential-netrc"       ; git-credential-netrc
                "credential-libsecret"   ; git-credential-libsecret
                "subtree"                ; git-subtree
+               "completion"             ; git-completion and git-prompt
                "gui"))                  ; gitk, git gui
     (arguments
      `(#:make-flags `("V=1"             ;more verbose compilation
@@ -482,6 +483,20 @@  (define-public git
                              (string-append subtree "/bin"))
                (install-file "contrib/subtree/git-subtree.1"
                              (string-append subtree "/share/man/man1")))))
+         (add-after 'install 'install-completion
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((completion (assoc-ref outputs "completion")))
+               (define (install-as file storename)
+                 (let ((storename (string-append completion storename)))
+                   (mkdir-p (dirname storename))
+                   (copy-file file storename)))
+               (with-directory-excursion "contrib/completion"
+                 (for-each (cut apply install-as <>)
+                           `(("git-prompt.sh" "/bin/git-prompt")
+                             ("git-completion.bash"
+                              "/share/bash-completion/completions/_git")
+                             ("git-completion.zsh"
+                              "/share/zsh/site-functions/_git")))))))
          (add-after 'install 'restore-sample-hooks-shebang
            (lambda* (#:key outputs #:allow-other-keys)
              (let* ((out (assoc-ref outputs "out"))