File tree 2 files changed +34
-0
lines changed
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.
8
8
The file ` .gitconsensus.yaml ` needs to be placed in the repository to be managed. Any rule set to ` false ` or ommitted
9
9
will be skipped.
10
10
11
+ You can run ` gitconsensus init ` to start with a template configuration in the current working directory.
12
+
11
13
``` yaml
12
14
# Which version of the consensus rules to use
13
15
version : 3
@@ -95,6 +97,15 @@ gitconsensus auth
95
97
You will be asked for your username, password, and 2fa token (if configured). This will be used to get an authentication
96
98
token from Github that will be used in place of your username and password (which are never saved).
97
99
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
+
98
109
# ## Merge
99
110
100
111
Merge all pull requests that meet consensus rules.
Original file line number Diff line number Diff line change 2
2
import github3
3
3
import os
4
4
import random
5
+ import requests
5
6
from gitconsensus import config
6
7
from gitconsensus .repository import Repository
7
8
import string
@@ -31,6 +32,28 @@ def twofacallback(*args):
31
32
fd .write (auth .token + '\n ' )
32
33
33
34
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
+
34
57
@cli .command (short_help = "List open pull requests and their status" )
35
58
@click .argument ('username' )
36
59
@click .argument ('repository_name' )
You can’t perform that action at this time.
0 commit comments