File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ merge (or close) pull requests.
88The file ` .gitconsensus.yaml ` needs to be placed in the repository to be managed. Any rule set to ` false ` or ommitted
99will be skipped.
1010
11+ You can run ` gitconsensus init ` to start with a template configuration in the current working directory.
12+
1113``` yaml
1214# Which version of the consensus rules to use
1315version : 3
@@ -95,6 +97,15 @@ gitconsensus auth
9597You will be asked for your username, password, and 2fa token (if configured). This will be used to get an authentication
9698token from Github that will be used in place of your username and password (which are never saved).
9799
100+ # ## Initialization
101+
102+ Initialize the configuration for a specific project. If no template is provided the `recommended` settings will be used.
103+ All settings come from the [gitconsensus_examples](https://github.com/gitconsensus/gitconsensus_examples) project.
104+
105+ ` ` ` shell
106+ gitconsensus init [TEMPLATE]
107+ ` ` `
108+
98109# ## Merge
99110
100111Merge all pull requests that meet consensus rules.
Original file line number Diff line number Diff line change 22import github3
33import os
44import random
5+ import requests
56from gitconsensus import config
67from gitconsensus .repository import Repository
78import string
@@ -31,6 +32,28 @@ def twofacallback(*args):
3132 fd .write (auth .token + '\n ' )
3233
3334
35+ @cli .command (short_help = "Create a new gitconsensus configuration" )
36+ @click .argument ('template' , required = False )
37+ def init (template ):
38+ if not template :
39+ template = 'recommended'
40+
41+ if os .path .isfile ('.gitconsensus.yaml' ):
42+ click .echo ('.gitconsensus.yaml already exists.' )
43+ exit (- 1 )
44+
45+ baseurl = 'https://raw.githubusercontent.com/gitconsensus/gitconsensus_examples/master/examples/%s/.gitconsensus.yaml'
46+ url = baseurl % (template )
47+ response = requests .get (url )
48+
49+ if not response .ok :
50+ click .echo ('Unable to find template "%s"' % (template ))
51+ exit (- 1 )
52+
53+ with open ('.gitconsensus.yaml' , 'wb' ) as f :
54+ f .write (response .content )
55+
56+
3457@cli .command (short_help = "List open pull requests and their status" )
3558@click .argument ('username' )
3659@click .argument ('repository_name' )
You can’t perform that action at this time.
0 commit comments