diff options
| author | Gauvain Pocentek <gauvain.pocentek@objectif-libre.com> | 2015-09-19 11:56:50 +0200 |
|---|---|---|
| committer | Gauvain Pocentek <gauvain.pocentek@objectif-libre.com> | 2015-09-19 11:56:50 +0200 |
| commit | 9c58013a269d3da2beec947a152605fc3c926577 (patch) | |
| tree | 21722a27de45fddc4aa34b35f3c153f8f754ca8a /gitlab | |
| parent | 3270865977fcf5375b0d99e06ef6cf842eb406e9 (diff) | |
| download | gitlab-9c58013a269d3da2beec947a152605fc3c926577.tar.gz | |
Fix GET/POST for project files
Diffstat (limited to 'gitlab')
| -rw-r--r-- | gitlab/__init__.py | 5 | ||||
| -rw-r--r-- | gitlab/cli.py | 9 |
2 files changed, 9 insertions, 5 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py index 7872ecf..45bbf08 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -675,6 +675,8 @@ class GitlabObject(object): requiredUpdateAttrs = None #: Attributes that are optional when updating an object optionalUpdateAttrs = None + #: Whether the object ID is required in the GET url + getRequiresId = True idAttr = 'id' shortPrintAttr = None @@ -1134,7 +1136,8 @@ class ProjectFile(GitlabObject): optionalCreateAttrs = ['encoding'] requiredDeleteAttrs = ['branch_name', 'commit_message'] getListWhenNoId = False - shortPrintAttr = 'name' + shortPrintAttr = 'file_path' + getRequiresId = False class ProjectSnippetNote(GitlabObject): diff --git a/gitlab/cli.py b/gitlab/cli.py index 68a589f..a1109b6 100644 --- a/gitlab/cli.py +++ b/gitlab/cli.py @@ -82,9 +82,10 @@ def populate_sub_parser_by_class(cls, sub_parser): elif action_name in [GET, DELETE]: if cls not in [gitlab.CurrentUser]: - id_attr = cls.idAttr.replace('_', '-') - sub_parser_action.add_argument("--%s" % id_attr, - required=True) + if cls.getRequiresId: + id_attr = cls.idAttr.replace('_', '-') + sub_parser_action.add_argument("--%s" % id_attr, + required=True) [sub_parser_action.add_argument("--%s" % x.replace('_', '-'), required=True) for x in cls.requiredGetAttrs] @@ -172,7 +173,7 @@ def do_get(cls, gl, what, args): die("%s objects can't be retrieved" % what) id = None - if cls not in [gitlab.CurrentUser]: + if cls not in [gitlab.CurrentUser] and cls.getRequiresId: id = get_id(cls, args) try: |
