Skip to content

Commit f0b4211

Browse files
committed
Add command to set colors for built in labels
1 parent b019496 commit f0b4211

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

gitconsensus/gitconsensus.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,24 @@ def close(username, repository_name):
105105
request.addInfoLabels()
106106
request.close()
107107

108+
109+
@cli.command(short_help="Add labels and set colors")
110+
@click.argument('username')
111+
@click.argument('repository_name')
112+
@click.option('--color-negative', default='#ee0701')
113+
@click.option('--color-positive', default='#0052cc')
114+
@click.option('--color-notice', default='#fbf904')
115+
def createlabels(username, repository_name, color_negative, color_positive, color_notice):
116+
repo = Repository(username, repository_name)
117+
repo.setLabelColor('License Change', color_notice)
118+
repo.setLabelColor('Consensus Change', color_notice)
119+
repo.setLabelColor('Has Quorum', color_positive)
120+
repo.setLabelColor('Needs Votes', color_negative)
121+
repo.setLabelColor('Passing', color_positive)
122+
repo.setLabelColor('Failing', color_negative)
123+
repo.setLabelColor('gc-merged', color_positive)
124+
repo.setLabelColor('gc-closed', color_negative)
125+
126+
108127
if __name__ == '__main__':
109128
cli()

gitconsensus/repository.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ def isCollaborator(username):
8989
def getConsensus(self):
9090
return Consensus(self.rules)
9191

92+
def setLabelColor(self, name, color):
93+
try:
94+
self.repository.create_label(name, color)
95+
except:
96+
self.repository.update_label(name, color)
97+
9298

9399
class PullRequest:
94100
labels = False

0 commit comments

Comments
 (0)