Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit53562b3

Browse files
author
Gauvain Pocentek
committed
manage project branch protection with the cmd line
1 parent33c771d commit53562b3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

‎gitlab

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ import gitlab
3131

3232
camel_re=re.compile('(.)([A-Z])')
3333

34+
extra_actions= {
35+
gitlab.ProjectBranch: {
36+
'protect': {'requiredAttrs': ['id','project-id'] },
37+
'unprotect': {'requiredAttrs': ['id','project-id'] }
38+
},
39+
}
40+
3441
defdie(msg):
3542
sys.stderr.write(msg+"\n")
3643
sys.exit(1)
@@ -74,6 +81,12 @@ def actionHelpList(cls):
7481
detail+=" ".join(["[--%s=ARG]"%x.replace('_','-')forxincls.optionalCreateAttrs])
7582
l.append("%s %s"% (action,detail))
7683

84+
ifextra_actions.has_key(cls):
85+
foractioninsorted(extra_actions[cls]):
86+
d=extra_actions[cls][action]
87+
detail=" ".join(["--%s=ARG"%argforargind['requiredAttrs']])
88+
l.append("%s %s"% (action,detail))
89+
7790
return (l)
7891

7992
defusage():
@@ -301,6 +314,20 @@ elif action == "delete":
301314
elifaction=="update":
302315
o=do_update(cls,d)
303316

317+
elifaction=="protect":
318+
ifcls!=gitlab.ProjectBranch:
319+
die("%s objects can't be protected"%what)
320+
321+
o=do_get(cls,d)
322+
o.protect()
323+
324+
elifaction=="unprotect":
325+
ifcls!=gitlab.ProjectBranch:
326+
die("%s objects can't be protected"%what)
327+
328+
o=do_get(cls,d)
329+
o.unprotect()
330+
304331
else:
305332
die("Unknown action: %s. Use\"gitlab %s help\" to get details."% (action,what))
306333

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp