summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gitlab/__init__.py5
-rw-r--r--gitlab/cli.py9
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: