Merge lp:~jelmer/brz/gitlab-interactive into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/gitlab-interactive
Merge into: lp:brz
Diff against target: 49 lines (+13/-4)
1 file modified
breezy/plugins/propose/cmds.py (+13/-4)
To merge this branch: bzr merge lp:~jelmer/brz/gitlab-interactive
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+362154@code.launchpad.net

Commit message

Support interactive login for GitLab sites.

Description of the change

Support interactive login for GitLab sites.

This informs users of the URL they can visit to create a private token and then
prompts them for it.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/plugins/propose/cmds.py'
2--- breezy/plugins/propose/cmds.py 2019-01-05 14:18:03 +0000
3+++ breezy/plugins/propose/cmds.py 2019-01-24 01:06:53 +0000
4@@ -268,17 +268,21 @@
5 __doc__ = """Log into a GitLab instance.
6
7 This command takes a GitLab instance URL (e.g. https://gitlab.com)
8- as well as a private token. Private tokens can be created via the
9+ as well as an optional private token. Private tokens can be created via the
10 web UI.
11
12 :Examples:
13
14- Log into Debian's salsa:
15+ Log into GNOME's GitLab (prompts for a token):
16+
17+ brz gitlab-login https://gitlab.gnome.org/
18+
19+ Log into Debian's salsa, using a token created earlier:
20
21 brz gitlab-login https://salsa.debian.org if4Theis6Eich7aef0zo
22 """
23
24- takes_args = ['url', 'private_token']
25+ takes_args = ['url', 'private_token?']
26
27 takes_options = [
28 Option('name', help='Name for GitLab site in configuration.',
29@@ -287,7 +291,8 @@
30 "Don't check that the token is valid."),
31 ]
32
33- def run(self, url, private_token, name=None, no_check=False):
34+ def run(self, url, private_token=None, name=None, no_check=False):
35+ from breezy import ui
36 from .gitlabs import store_gitlab_token
37 if name is None:
38 try:
39@@ -295,6 +300,10 @@
40 except (ValueError, IndexError):
41 raise errors.BzrCommandError(
42 'please specify a site name with --name')
43+ if private_token is None:
44+ note("Please visit %s to obtain a private token.",
45+ urlutils.join(url, "profile/personal_access_tokens"))
46+ private_token = ui.ui_factory.get_password(u'Private token')
47 if not no_check:
48 from gitlab import Gitlab
49 gl = Gitlab(url=url, private_token=private_token)

Subscribers

People subscribed via source and target branches