Skip to content

Please implement getting project by namespace/name #28

Closed

Description

@marcinant

Currently gitlab cli supports 'project get' by project id only, while Gitlab API supports getting specific project also by namespace/project_name

"Get a specific project, identified by project ID or NAMESPACE/PROJECT_NAME, which is owned by the authenticated user. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded, eg. /api/v3/projects/diaspora%2Fdiaspora (where / is represented by %2F)."

In this way user can get project ID knowing only it's name and reuse this ID later (to add milestone or issue etc.)

Currently I have to store project ID's somewhere to use them with CLI.

I could also try to use "project search" or parse output from "project list" command but it's overcomplicated.

Activity

  1. cdbennett commented on Dec 23, 2015

    @cdbennett

    I think this is broken again. Tested on 0.9+ (acc1511). I have to specify %2F instead of a slash:

    cbennett@AP-CBENNETT MINGW64 /c/work/python-gitlab (pu)
    $ gitlab -c test.ini project get --id sandbox/msgparsedemo
    Impossible to get object (Expecting value: line 1 column 1 (char 0))
    
    cbennett@AP-CBENNETT MINGW64 /c/work/python-gitlab (pu)
    $ gitlab -c test.ini project get --id sandbox%2Fmsgparsedemo
    id: 34
    path: msgparsedemo
    
    cbennett@AP-CBENNETT MINGW64 /c/work/python-gitlab (pu)
    $
    
  2. added a commit that references this issue on Dec 24, 2015
    5d88f68
  3. cdbennett commented on Dec 30, 2015

    @cdbennett

    👍 Awesome, tested and fixed.

  4. derekschrock commented on Feb 11, 2018

    @derekschrock
    Contributor

    Does this only apply to 'gitlab project' or 'gitlab project get' or should you not expect this same symbolic naming for other commands/subcomamnds that have a --project-id or --id? ex: 'gitlab project-commit-comment list --commit-id ... --project-id' This is still expecting a number.

    If so I'd highly recommend this in every instance where a --project-id or --id that a group/project should be allowed.

    If you agree would you like a issue per command or per subcommand or a large meta issue be alright?

  5. gpocentek commented on Feb 14, 2018

    @gpocentek
    Contributor

    @derekschrock this works for project get but not for other subcommands (--project-id namespace/name doesn't work).

    I'd rather have a single issue. Thanks!

  6. jgeorgeson commented on Feb 14, 2018

    @jgeorgeson

    I'm able to use path%2fname for --project-id and --group-id everywhere I've tried it, including subgroup projects. Though I would greatly prefer '/' instead of '%2f'.

  7. derekschrock commented on Feb 15, 2018

    @derekschrock
    Contributor

    Appears to be a v4 issue? Works as expected in v3.

  8. derekschrock commented on Feb 15, 2018

    @derekschrock
    Contributor
    $ gitlab project-issue list --project-id 'issues/issues' # with v3
    id: 4
    title: Testing123
    
    id: 3
    title: Testing
    
    $ gitlab project-issue list --project-id 'issues/issues' # with v4
    Impossible to list objects (400: {"error":"issue_iid is invalid"})
    
    $ gitlab project-issue list --project-id 'issues%2Fissues' # with v4
    iid: 2
    title: Testing123
    
    iid: 1
    title: Testing
    
  9. derekschrock commented on Feb 17, 2018

    @derekschrock
    Contributor

    My 100th first try at doing python but I think this should fix it?

    diff --git a/gitlab/v4/cli.py b/gitlab/v4/cli.py
    index 939a7cc..fb84be3 100644
    --- a/gitlab/v4/cli.py
    +++ b/gitlab/v4/cli.py
    @@ -42,6 +42,8 @@ class GitlabCLI(object):
             # parents, build the chain of managers to get to the final object.
             # Instead we do something ugly and efficient: interpolate variables in
             # the class _path attribute, and replace the value with the result.
    +        if 'project_id' in self.args:
    +            self.args['project_id'] = self.args['project_id'].replace('/', '%2F')
             self.mgr_cls._path = self.mgr_cls._path % self.args
             self.mgr = self.mgr_cls(gl)
    
    
  10. locked as resolved and limited conversation to collaborators on Nov 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions