/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/plugins/propose/cmds.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2019-01-29 00:05:33 UTC
  • mfrom: (7241.1.2 gitlab-interactive)
  • Revision ID: breezy.the.bot@gmail.com-20190129000533-cq9vh9bgbai3e7ix
Support interactive login for GitLab sites.

Merged from https://code.launchpad.net/~jelmer/brz/gitlab-interactive/+merge/362154

Show diffs side-by-side

added added

removed removed

Lines of Context:
268
268
    __doc__ = """Log into a GitLab instance.
269
269
 
270
270
    This command takes a GitLab instance URL (e.g. https://gitlab.com)
271
 
    as well as a private token. Private tokens can be created via the
 
271
    as well as an optional private token. Private tokens can be created via the
272
272
    web UI.
273
273
 
274
274
    :Examples:
275
275
 
276
 
      Log into Debian's salsa:
 
276
      Log into GNOME's GitLab (prompts for a token):
 
277
 
 
278
         brz gitlab-login https://gitlab.gnome.org/
 
279
 
 
280
      Log into Debian's salsa, using a token created earlier:
277
281
 
278
282
         brz gitlab-login https://salsa.debian.org if4Theis6Eich7aef0zo
279
283
    """
280
284
 
281
 
    takes_args = ['url', 'private_token']
 
285
    takes_args = ['url', 'private_token?']
282
286
 
283
287
    takes_options = [
284
288
        Option('name', help='Name for GitLab site in configuration.',
287
291
               "Don't check that the token is valid."),
288
292
        ]
289
293
 
290
 
    def run(self, url, private_token, name=None, no_check=False):
 
294
    def run(self, url, private_token=None, name=None, no_check=False):
 
295
        from breezy import ui
291
296
        from .gitlabs import store_gitlab_token
292
297
        if name is None:
293
298
            try:
295
300
            except (ValueError, IndexError):
296
301
                raise errors.BzrCommandError(
297
302
                    'please specify a site name with --name')
 
303
        if private_token is None:
 
304
            note("Please visit %s to obtain a private token.",
 
305
                 urlutils.join(url, "profile/personal_access_tokens"))
 
306
            private_token = ui.ui_factory.get_password(u'Private token')
298
307
        if not no_check:
299
308
            from gitlab import Gitlab
300
309
            gl = Gitlab(url=url, private_token=private_token)