@@ -254,7 +254,8 @@ def git_pull_request(target_remote=None, target_branch=None,
254
254
fork = True ,
255
255
setup_only = False ,
256
256
branch_prefix = None ,
257
- dry_run = False ):
257
+ dry_run = False ,
258
+ labels = None ):
258
259
branch = git_get_branch_name ()
259
260
if not branch :
260
261
LOG .critical ("Unable to find current branch" )
@@ -326,7 +327,7 @@ def git_pull_request(target_remote=None, target_branch=None,
326
327
retcode = fork_and_push_pull_request (
327
328
g , hosttype , repo , rebase , target_remote , target_branch , branch ,
328
329
user , title , message , comment , force_editor , tag_previous_revision ,
329
- fork , setup_only , branch_prefix , dry_run ,
330
+ fork , setup_only , branch_prefix , dry_run , labels ,
330
331
)
331
332
332
333
approve_login_password (host = hostname , user = user , password = password )
@@ -435,7 +436,8 @@ def fork_and_push_pull_request(g, hosttype, repo_to_fork, rebase,
435
436
title , message , comment ,
436
437
force_editor , tag_previous_revision , fork ,
437
438
setup_only , branch_prefix ,
438
- dry_run = False ):
439
+ dry_run = False ,
440
+ labels = None ):
439
441
440
442
g_user = g .get_user ()
441
443
@@ -553,6 +555,10 @@ def fork_and_push_pull_request(g, hosttype, repo_to_fork, rebase,
553
555
# that yet
554
556
repo_to_fork .get_issue (pull .number ).create_comment (comment )
555
557
LOG .debug ("Commented: \" %s\" " , comment )
558
+
559
+ if labels :
560
+ LOG .debug ("Adding labels %s" , labels )
561
+ pull .add_to_labels (* labels )
556
562
else :
557
563
if dry_run :
558
564
LOG .info ("Pull-request would be created." )
@@ -588,6 +594,10 @@ def fork_and_push_pull_request(g, hosttype, repo_to_fork, rebase,
588
594
else :
589
595
LOG .info ("Pull-request created: %s" , pull .html_url )
590
596
597
+ if labels :
598
+ LOG .debug ("Adding labels %s" , labels )
599
+ pull .add_to_labels (* labels )
600
+
591
601
if tag_previous_revision :
592
602
preserve_older_revision (branch , remote_to_push )
593
603
@@ -643,6 +653,9 @@ def build_parser():
643
653
help = "Title of the pull request." )
644
654
parser .add_argument ("--message" , "-m" ,
645
655
help = "Message of the pull request." )
656
+ parser .add_argument ("--label" , "-l" , action = 'append' ,
657
+ help = "The labels to add to the pull request. "
658
+ "Can be used multiple times." )
646
659
git_config_add_argument (parser ,
647
660
"--branch-prefix" ,
648
661
help = "Prefix remote branch" )
@@ -723,6 +736,7 @@ def main():
723
736
setup_only = args .setup_only ,
724
737
branch_prefix = args .branch_prefix ,
725
738
dry_run = args .dry_run ,
739
+ labels = args .label ,
726
740
)
727
741
except Exception :
728
742
LOG .error ("Unable to send pull request" , exc_info = True )
0 commit comments