Gentoo Archives: gentoo-commits

From: Andrew Ammerlaan <andrewammerlaan@××××××.net>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/guru:master commit in: dev-vcs/lazygit/, dev-vcs/lazygit/files/
Date: Sun, 11 Oct 2020 14:54:28
Message-Id: 1602336808.8a9d1f129ad73daa975a56f793d65200add3d8ed.andrewammerlaan@gentoo
1 commit: 8a9d1f129ad73daa975a56f793d65200add3d8ed
2 Author: Sergey Torokhov <torokhov-s-a <AT> yandex <DOT> ru>
3 AuthorDate: Sat Oct 10 13:29:10 2020 +0000
4 Commit: Andrew Ammerlaan <andrewammerlaan <AT> riseup <DOT> net>
5 CommitDate: Sat Oct 10 13:33:28 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=8a9d1f12
7
8 dev-vcs/lazygit: 0.23.1-r1, add SSH key passphrase prompt patch
9
10 Signed-off-by: Sergey Torokhov <torokhov-s-a <AT> yandex.ru>
11
12 .../files/lazygit-0.23.1_ssh_passphrase.patch | 122 +++++++++++++++++++++
13 dev-vcs/lazygit/lazygit-0.23.1-r1.ebuild | 38 +++++++
14 2 files changed, 160 insertions(+)
15
16 diff --git a/dev-vcs/lazygit/files/lazygit-0.23.1_ssh_passphrase.patch b/dev-vcs/lazygit/files/lazygit-0.23.1_ssh_passphrase.patch
17 new file mode 100644
18 index 00000000..11d63bdf
19 --- /dev/null
20 +++ b/dev-vcs/lazygit/files/lazygit-0.23.1_ssh_passphrase.patch
21 @@ -0,0 +1,122 @@
22 +diff -Naur a/src/github.com/jesseduffield/lazygit/pkg/commands/oscommands/os.go b/src/github.com/jesseduffield/lazygit/pkg/commands/oscommands/os.go
23 +--- a/src/github.com/jesseduffield/lazygit/pkg/commands/oscommands/os.go 2020-10-10 02:34:14.000000000 +0300
24 ++++ b/src/github.com/jesseduffield/lazygit/pkg/commands/oscommands/os.go 2020-10-10 14:00:26.000000000 +0300
25 +@@ -143,18 +143,19 @@
26 + return RunCommandWithOutputLiveWrapper(c, command, output)
27 + }
28 +
29 +-// DetectUnamePass detect a username / password question in a command
30 +-// promptUserForCredential is a function that gets executed when this function detect you need to fillin a password
31 +-// The promptUserForCredential argument will be "username" or "password" and expects the user's password or username back
32 ++// DetectUnamePass detect a username / password / passphrase question in a command
33 ++// promptUserForCredential is a function that gets executed when this function detect you need to fillin a password or passphrase
34 ++// The promptUserForCredential argument will be "username", "password" or "passphrase" and expects the user's password/passphrase or username back
35 + func (c *OSCommand) DetectUnamePass(command string, promptUserForCredential func(string) string) error {
36 + ttyText := ""
37 + errMessage := c.RunCommandWithOutputLive(command, func(word string) string {
38 + ttyText = ttyText + " " + word
39 +
40 + prompts := map[string]string{
41 +- `.+'s password:`: "password",
42 +- `Password\s*for\s*'.+':`: "password",
43 +- `Username\s*for\s*'.+':`: "username",
44 ++ `.+'s password:`: "password",
45 ++ `Password\s*for\s*'.+':`: "password",
46 ++ `Username\s*for\s*'.+':`: "username",
47 ++ `Enter\s*passphrase\s*for\s*key\s*'.+':`: "passphrase",
48 + }
49 +
50 + for pattern, askFor := range prompts {
51 +diff -Naur a/src/github.com/jesseduffield/lazygit/pkg/gui/credentials_panel.go b/src/github.com/jesseduffield/lazygit/pkg/gui/credentials_panel.go
52 +--- a/src/github.com/jesseduffield/lazygit/pkg/gui/credentials_panel.go 2020-10-10 02:34:14.000000000 +0300
53 ++++ b/src/github.com/jesseduffield/lazygit/pkg/gui/credentials_panel.go 2020-10-10 03:17:57.000000000 +0300
54 +@@ -9,7 +9,7 @@
55 +
56 + type credentials chan string
57 +
58 +-// promptUserForCredential wait for a username or password input from the credentials popup
59 ++// promptUserForCredential wait for a username, password or passphrase input from the credentials popup
60 + func (gui *Gui) promptUserForCredential(passOrUname string) string {
61 + gui.credentials = make(chan string)
62 + gui.g.Update(func(g *gocui.Gui) error {
63 +@@ -17,9 +17,12 @@
64 + if passOrUname == "username" {
65 + credentialsView.Title = gui.Tr.CredentialsUsername
66 + credentialsView.Mask = 0
67 +- } else {
68 ++ } else if passOrUname == "password" {
69 + credentialsView.Title = gui.Tr.CredentialsPassword
70 + credentialsView.Mask = '*'
71 ++ } else {
72 ++ credentialsView.Title = gui.Tr.CredentialsPassphrase
73 ++ credentialsView.Mask = '*'
74 + }
75 +
76 + if err := gui.switchContext(gui.Contexts.Credentials.Context); err != nil {
77 +@@ -30,7 +33,7 @@
78 + return nil
79 + })
80 +
81 +- // wait for username/passwords input
82 ++ // wait for username/passwords/passphrase input
83 + userInput := <-gui.credentials
84 + return userInput + "\n"
85 + }
86 +@@ -70,10 +73,10 @@
87 + func (gui *Gui) handleCredentialsPopup(cmdErr error) {
88 + if cmdErr != nil {
89 + errMessage := cmdErr.Error()
90 +- if strings.Contains(errMessage, "Invalid username or password") {
91 ++ if strings.Contains(errMessage, "Invalid username, password or passphrase") {
92 + errMessage = gui.Tr.PassUnameWrong
93 + }
94 +- // we are not logging this error because it may contain a password
95 ++ // we are not logging this error because it may contain a password or a passphrase
96 + gui.createErrorPanel(errMessage)
97 + } else {
98 + _ = gui.closeConfirmationPrompt(false)
99 +diff -Naur a/src/github.com/jesseduffield/lazygit/pkg/i18n/dutch.go b/src/github.com/jesseduffield/lazygit/pkg/i18n/dutch.go
100 +--- a/src/github.com/jesseduffield/lazygit/pkg/i18n/dutch.go 2020-10-10 02:34:14.000000000 +0300
101 ++++ b/src/github.com/jesseduffield/lazygit/pkg/i18n/dutch.go 2020-10-10 02:57:03.000000000 +0300
102 +@@ -19,6 +19,7 @@
103 + CommitMessage: "Commit bericht",
104 + CredentialsUsername: "Gebruikersnaam",
105 + CredentialsPassword: "Wachtwoord",
106 ++ CredentialsPassphrase: "Voer een wachtwoordzin in voor de SSH-sleutel",
107 + PassUnameWrong: "Wachtwoord en/of gebruikersnaam verkeert",
108 + CommitChanges: "Commit veranderingen",
109 + AmendLastCommit: "wijzig laatste commit",
110 +diff -Naur a/src/github.com/jesseduffield/lazygit/pkg/i18n/english.go b/src/github.com/jesseduffield/lazygit/pkg/i18n/english.go
111 +--- a/src/github.com/jesseduffield/lazygit/pkg/i18n/english.go 2020-10-10 02:34:14.000000000 +0300
112 ++++ b/src/github.com/jesseduffield/lazygit/pkg/i18n/english.go 2020-10-10 02:56:08.000000000 +0300
113 +@@ -30,6 +30,7 @@
114 + CommitMessage string
115 + CredentialsUsername string
116 + CredentialsPassword string
117 ++ CredentialsPassphrase string
118 + PassUnameWrong string
119 + CommitChanges string
120 + AmendLastCommit string
121 +@@ -519,7 +520,8 @@
122 + CommitMessage: "Commit message",
123 + CredentialsUsername: "Username",
124 + CredentialsPassword: "Password",
125 +- PassUnameWrong: "Password and/or username wrong",
126 ++ CredentialsPassphrase: "Enter passphrase for SSH key",
127 ++ PassUnameWrong: "Password, passphrase and/or username wrong",
128 + CommitChanges: "commit changes",
129 + AmendLastCommit: "amend last commit",
130 + SureToAmend: "Are you sure you want to amend last commit? Afterwards, you can change commit message from the commits panel.",
131 +diff -Naur a/src/github.com/jesseduffield/lazygit/pkg/i18n/polish.go b/src/github.com/jesseduffield/lazygit/pkg/i18n/polish.go
132 +--- a/src/github.com/jesseduffield/lazygit/pkg/i18n/polish.go 2020-10-10 02:34:14.000000000 +0300
133 ++++ b/src/github.com/jesseduffield/lazygit/pkg/i18n/polish.go 2020-10-10 02:49:23.000000000 +0300
134 +@@ -15,7 +15,8 @@
135 + CommitMessage: "Wiadomość commita",
136 + CredentialsUsername: "Username",
137 + CredentialsPassword: "Password",
138 +- PassUnameWrong: "Password and/or username wrong",
139 ++ CredentialsPassphrase: "Passphrase",
140 ++ PassUnameWrong: "Password, passphrase and/or username wrong",
141 + CommitChanges: "commituj zmiany",
142 + AmendLastCommit: "zmień ostatnie zatwierdzenie",
143 + SureToAmend: "Czy na pewno chcesz zmienić ostatnie zatwierdzenie? Możesz zmienić komunikat zatwierdzenia z panelu zatwierdzeń.",
144
145 diff --git a/dev-vcs/lazygit/lazygit-0.23.1-r1.ebuild b/dev-vcs/lazygit/lazygit-0.23.1-r1.ebuild
146 new file mode 100644
147 index 00000000..b73db124
148 --- /dev/null
149 +++ b/dev-vcs/lazygit/lazygit-0.23.1-r1.ebuild
150 @@ -0,0 +1,38 @@
151 +# Copyright 1999-2020 Gentoo Authors
152 +# Distributed under the terms of the GNU General Public License v2
153 +
154 +EAPI=7
155 +
156 +EGO_PN="github.com/jesseduffield/lazygit"
157 +
158 +inherit golang-build golang-vcs-snapshot
159 +
160 +DESCRIPTION="Lazygit, a simple terminal UI for git commands"
161 +HOMEPAGE="https://github.com/jesseduffield/lazygit"
162 +SRC_URI="https://github.com/jesseduffield/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
163 +
164 +LICENSE="MIT"
165 +SLOT="0"
166 +KEYWORDS="~amd64"
167 +IUSE="doc"
168 +
169 +DEPEND=( sys-libs/glibc )
170 +RDEPEND=(
171 + ${DEPEND}
172 + dev-vcs/git
173 +)
174 +
175 +DOCS=( src/${EGO_PN}/{CONTRIBUTING,README}.md )
176 +
177 +PATCHES=( "${FILESDIR}/${P}_ssh_passphrase.patch" )
178 +
179 +src_compile() {
180 + GOPATH="${S}" go build -v -o bin/lazygit src/${EGO_PN}/main.go || die
181 +}
182 +
183 +src_install() {
184 + dobin bin/lazygit
185 +
186 + use doc && dodoc -r "src/${EGO_PN}/docs/."
187 + einstalldocs
188 +}