Subject: [bug#47539] [PATCH v3 25/25] gnu: Add github-cli.

From: Xinglu Chen <[email-masked]>
Date: Mon, 19 Apr 2021 17:24:14 +0200

* gnu/packages/version-control.scm (github-cli): New variable.
---
 gnu/packages/version-control.scm | 145 +++++++++++++++++++++++++++++++
 1 file changed, 145 insertions(+)

diff --git a/gnu/packages/version-control.scm b/gnu/packages/version-control.scm
index ebddd9522a..da6f71ccfe 100644
--- a/gnu/packages/version-control.scm
+++ b/gnu/packages/version-control.scm
@@ -118,6 +118,7 @@
   #:use-module (gnu packages sdl)
   #:use-module (gnu packages swig)
   #:use-module (gnu packages sync)
+  #:use-module ((gnu packages syncthing) #:select (go-github-com-kballard-go-shellquote))
   #:use-module (gnu packages tcl)
   #:use-module (gnu packages textutils)
   #:use-module (gnu packages time)
@@ -3021,6 +3022,150 @@ commit message side by side
 If several repos are related, it helps to see their status together.")
       (license license:expat))))
 
+(define-public github-cli
+  (package
+    (name "github-cli")
+    (version "1.8.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/cli/cli.git")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "009jh1i1ji7d773ismifdw4qvwlb8s1zn14d0n84j9h3n0hyynbc"))))
+    (build-system go-build-system)
+    (arguments
+     '(#:import-path
+       "github.com/cli/cli/cmd/gh"
+       #:unpack-path
+       "github.com/cli/cli"
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'remove-safeexec
+           (lambda* (#:key outputs #:allow-other-keys)
+             (with-directory-excursion "src/github.com/cli/cli/"
+               ;; 'github.com/cli/safeexec' is only used for Windows, we
+               ;; replace it with the regular 'os/exec'.  See
+               ;; <https://issues.guix.gnu.org/47539> for discussion.
+               (substitute* '("pkg/cmd/alias/expand/expand.go"
+                              "script/build.go")
+                 (("github.com/cli/safeexec") "os/exec")
+                 (("safeexec") "exec"))
+               ;; These files have already imported 'os/exec', meaning that
+               ;; 'os/exec' would get imported twice, causing an error.
+               ;; Instead, we just remove the 'github.com/cli/safeexec'.
+               (substitute* '("cmd/gh/main.go"
+                              "git/git.go"
+                              "pkg/iostreams/iostreams.go"
+                              "pkg/cmd/auth/shared/ssh_keys.go"
+                              "pkg/cmd/pr/checkout/checkout.go"
+                              "pkg/cmdutil/web_browser.go"
+                              "pkg/surveyext/editor_manual.go")
+                 (("\"github.com/cli/safeexec\"") "")
+                 (("safeexec") "exec"))))))))
+    (native-inputs
+     `(("go-github-com-cli-shurcool-graphql"
+        ,go-github-com-cli-shurcool-graphql)
+       ("go-gopkg-in-yaml-v3" ,go-gopkg-in-yaml-v3)
+       ("go-golang-org-x-text" ,go-golang-org-x-text)
+       ("go-golang-org-x-sync" ,go-golang-org-x-sync)
+       ("go-golang-org-x-crypto"
+        ,go-golang-org-x-crypto)
+       ("go-github-com-stretchr-testify"
+        ,go-github-com-stretchr-testify)
+       ("go-github-com-spf13-pflag"
+        ,go-github-com-spf13-pflag)
+       ("go-github-com-spf13-cobra"
+        ,go-github-com-spf13-cobra)
+       ("go-github-com-shurcool-githubv4"
+        ,go-github-com-shurcool-githubv4)
+       ("go-github-com-rivo-uniseg"
+        ,go-github-com-rivo-uniseg)
+       ("go-github-com-muesli-termenv"
+        ,go-github-com-muesli-termenv)
+       ("go-github-com-mitchellh-go-homedir"
+        ,go-github-com-mitchellh-go-homedir)
+       ("go-github-com-mgutz-ansi"
+        ,go-github-com-mgutz-ansi)
+       ("go-github-com-mattn-go-runewidth"
+        ,go-github-com-mattn-go-runewidth)
+       ("go-github-com-mattn-go-isatty"
+        ,go-github-com-mattn-go-isatty)
+       ("go-github-com-mattn-go-colorable"
+        ,go-github-com-mattn-go-colorable)
+       ("go-github-com-kballard-go-shellquote"
+        ,go-github-com-kballard-go-shellquote)
+       ("go-github-com-itchyny-gojq"
+        ,go-github-com-itchyny-gojq)
+       ("go-github-com-henvic-httpretty"
+        ,go-github-com-henvic-httpretty)
+       ("go-github-com-hashicorp-go-version"
+        ,go-github-com-hashicorp-go-version)
+       ("go-github-com-google-shlex"
+        ,go-github-com-google-shlex)
+       ("go-github-com-google-go-cmp-cmp"
+        ,go-github-com-google-go-cmp-cmp)
+       ("go-github-com-gabriel-vasile-mimetype"
+        ,go-github-com-gabriel-vasile-mimetype)
+       ("go-github-com-enescakir-emoji"
+        ,go-github-com-enescakir-emoji)
+       ("go-github-com-cpuguy83-go-md2man-v2"
+        ,go-github-com-cpuguy83-go-md2man-v2)
+       ("go-github-com-cli-oauth"
+        ,go-github-com-cli-oauth)
+       ("go-github-com-cli-browser"
+        ,go-github-com-cli-browser)
+       ("go-github-com-briandowns-spinner"
+        ,go-github-com-briandowns-spinner)
+       ("go-github-com-makenowjust-heredoc"
+        ,go-github-com-makenowjust-heredoc)
+       ("go-github-com-alecaivazis-survey-v2"
+        ,go-github-com-alecaivazis-survey-v2)
+       ("go-github-com-charmbracelet-glamour"
+        ,go-github-com-charmbracelet-glamour)
+       ("go-github-com-alecthomas-chroma"
+        ,go-github-com-alecthomas-chroma)
+       ("go-github-com-google-goterm"
+        ,go-github-com-google-goterm)
+       ("go-github-com-aymerick-douceur"
+        ,go-github-com-aymerick-douceur)
+       ("go-github-com-danwakefield-fnmatch"
+        ,go-github-com-danwakefield-fnmatch)
+       ("go-github-com-chris-ramon-douceur"
+        ,go-github-com-chris-ramon-douceur)
+       ("go-github-com-gorilla-css"
+        ,go-github-com-gorilla-css)
+       ("go-golang-org-colorful"
+        ,go-golang-org-colorful)
+       ("go-golang-org-x-net"
+        ,go-golang-org-x-net)
+       ("go-github-com-muesli-reflow-ansi"
+        ,go-github-com-muesli-reflow-ansi)
+       ("go-github-com-microcosm-cc-bluemonday"
+        ,go-github-com-microcosm-cc-bluemonday)
+       ("go-github-com-muesli-reflow-wordwrap"
+        ,go-github-com-muesli-reflow-wordwrap)
+       ("go-github-com-yuin-goldmark"
+        ,go-github-com-yuin-goldmark)
+       ("go-github-com-dlclark-regexp2"
+        ,go-github-com-dlclark-regexp2)
+       ("go-github-com-muesli-reflow-indent"
+        ,go-github-com-muesli-reflow-indent)
+       ("go-github-com-muesli-reflow-padding"
+        ,go-github-com-muesli-reflow-padding)
+       ("go-github-com-olekukonko-tablewriter"
+        ,go-github-com-olekukonko-tablewriter)))
+    (home-page "https://github.com/cli/cli")
+    (synopsis "CLI interface to GitHub")
+    (description "This package provides the @command{gh} command, an interface
+to GitHub on the command line.  It brings pull requests, issues, and other
+GitHub concepts to the terminal next to where you are already working with Git
+and your code.")
+    (license license:expat)))
+
 (define-public ghq
   (package
     (name "ghq")
-- 
2.31.1