1
1
import click
2
- import re
3
- from gitconsensusservice .services import github
4
2
import yaml
5
- from gitconsensus .repository import Repository
3
+ from gitconsensusservice import app
4
+ from services .githubapp import gh
5
+ from jobs import consensus
6
6
7
7
8
8
@click .group ()
@@ -14,50 +14,48 @@ def cli(ctx):
14
14
15
15
@cli .command (short_help = "List installation IDs available to this application." )
16
16
def installs ():
17
- installs = github .get_installations ()
17
+ installs = gh .get_installations ()
18
18
for install in installs :
19
19
click .echo (install )
20
20
21
21
22
22
@cli .command (short_help = "List details about a specific installation." )
23
23
@click .argument ('install_id' )
24
24
def install (install_id ):
25
- dump (github . get_installation (install_id ))
25
+ dump (get_githubapp_install (install_id ). get_details ( ))
26
26
27
27
28
28
@cli .command (short_help = "Get an authentication token for the provided installation." )
29
29
@click .argument ('install_id' )
30
30
def install_token (install_id ):
31
- token = github .get_installation_token (install_id )
32
- click .echo (token )
31
+ dump (get_githubapp_install (install_id ).get_auth_token ())
33
32
34
33
35
- @cli .command (short_help = "Get an authentication token for the provided installation." )
34
+ @cli .command (short_help = "List all repositories for an installation." )
36
35
@click .argument ('install_id' )
37
36
def install_repos (install_id ):
38
- token = github .get_installation_repositories (install_id )
39
- dump (token )
37
+ dump (get_githubapp_install (install_id ).get_repositories ())
40
38
41
39
42
40
@cli .command (short_help = "List details about the current application." )
43
41
def application ():
44
- dump (github .get_app ())
42
+ dump (gh .get_app ())
45
43
46
44
47
45
@cli .command (short_help = "Get JWT Authentication Token for this application." )
48
46
def jwt ():
49
- click .echo (github .get_jwt ())
47
+ click .echo (gh .get_jwt ())
50
48
51
49
52
50
@cli .command (short_help = "List all open pull requests for the specific install and repository." )
53
51
@click .argument ('install_id' )
54
52
@click .argument ('username' )
55
53
@click .argument ('repository_name' )
56
54
def prs (install_id , username , repository_name ):
57
- dump (github .list_prs (install_id , username , repository_name ))
55
+ dump (get_githubapp_install ( install_id ) .list_prs (username , repository_name ))
58
56
59
57
60
- @cli .command (short_help = "Display detailed information about a specific pull request" )
58
+ @cli .command (short_help = "Display detailed information about a specific pull request. " )
61
59
@click .argument ('install_id' )
62
60
@click .argument ('username' )
63
61
@click .argument ('repository_name' )
@@ -77,9 +75,18 @@ def pr(install_id, username, repository_name, pull_request):
77
75
click .echo ("Last Update: %s" % (request .hoursSinceLastUpdate (),))
78
76
79
77
78
+ @cli .command (short_help = "Process pull requests for all installations." )
79
+ @click .option ('--synchronous/--no-synchronous' , default = True )
80
+ def process (synchronous ):
81
+ consensus .process_installs (synchronous )
82
+
83
+
84
+ def get_githubapp_install (install_id ):
85
+ return gh .get_installation (install_id )
86
+
87
+
80
88
def get_repository (install_id , username , repository_name ):
81
- client = github .get_github3_client (install_id )
82
- return Repository (username , repository_name , client )
89
+ return get_githubapp_install (install_id ).get_repository (username , repository_name )
83
90
84
91
85
92
def dump (obj ):
0 commit comments