|
1 | 1 | from github import Github |
2 | 2 | from stdiomask import getpass |
3 | | -from config import branch_name |
| 3 | +from config import branches |
4 | 4 | from config import branch_rules |
5 | 5 | from config import signed_commit |
6 | 6 | from config import add_codeowners_file |
|
9 | 9 | def add_all(pat): |
10 | 10 | print("") |
11 | 11 | for repo in git.get_organization(org_name).get_repos(): |
| 12 | + for branch_name in branches: |
| 13 | + branch = repo.get_branch(branch_name) |
| 14 | + if(add_codeowners_file): |
| 15 | + codeowners.add(org_name,pat,repo.name,branch_name) |
| 16 | + branch.edit_protection(**branch_rules) |
| 17 | + if(signed_commit): |
| 18 | + branch.add_required_signatures() |
| 19 | + else: |
| 20 | + branch.remove_required_signatures() |
| 21 | + print("Edited the branch protection rules for: " + repo.name + "," + branch_name) |
| 22 | + |
| 23 | +def add_one(pat): |
| 24 | + repo_name = input("\nRepository: ") |
| 25 | + repo = git.get_repo(org_name+"/"+repo_name) |
| 26 | + for branch_name in branches: |
12 | 27 | branch = repo.get_branch(branch_name) |
13 | 28 | if(add_codeowners_file): |
14 | | - codeowners.add(org_name,pat,repo.name,branch_name) |
| 29 | + codeowners.add(org_name,pat,repo_name,branch_name) |
15 | 30 | branch.edit_protection(**branch_rules) |
16 | 31 | if(signed_commit): |
17 | 32 | branch.add_required_signatures() |
18 | 33 | else: |
19 | 34 | branch.remove_required_signatures() |
20 | | - print("Edited the branch protection rules for: " + repo.name) |
21 | | - |
22 | | -def add_one(pat): |
23 | | - repo_name = input("\nRepository: ") |
24 | | - repo = git.get_repo(org_name+"/"+repo_name) |
25 | | - branch = repo.get_branch(branch_name) |
26 | | - if(add_codeowners_file): |
27 | | - codeowners.add(org_name,pat,repo_name,branch_name) |
28 | | - branch.edit_protection(**branch_rules) |
29 | | - if(signed_commit): |
30 | | - branch.add_required_signatures() |
31 | | - else: |
32 | | - branch.remove_required_signatures() |
33 | | - print("Edited the branch protection rules for: " + repo.name) |
| 35 | + print("Edited the branch protection rules for: " + repo.name + "," + branch_name) |
34 | 36 |
|
35 | 37 | def remove_one(): |
36 | 38 | repo_name = input("\nRepository: ") |
37 | 39 | repo = git.get_repo(org_name+"/"+repo_name) |
38 | | - branch = repo.get_branch(branch_name) |
39 | | - if (branch.protected): |
40 | | - branch.remove_protection() |
41 | | - print("Removed branch protection rules for: " + repo.name) |
42 | | - else: |
43 | | - print("No branch protection rules for: " + repo.name + "," + branch.name) |
44 | | - |
45 | | -def remove_all(): |
46 | | - print("") |
47 | | - for repo in git.get_organization(org_name).get_repos(): |
| 40 | + for branch_name in branches: |
48 | 41 | branch = repo.get_branch(branch_name) |
49 | 42 | if (branch.protected): |
50 | 43 | branch.remove_protection() |
51 | | - print("Removed branch protection rules for: " + repo.name) |
| 44 | + print("Removed branch protection rules for: " + repo.name + "," + branch_name) |
52 | 45 | else: |
53 | | - print("No branch protection rules for: " + repo.name + "," + branch.name) |
| 46 | + print("No branch protection rules for: " + repo.name + "," + branch.name) |
| 47 | + |
| 48 | +def remove_all(): |
| 49 | + print("") |
| 50 | + for repo in git.get_organization(org_name).get_repos(): |
| 51 | + for branch_name in branches: |
| 52 | + branch = repo.get_branch(branch_name) |
| 53 | + if (branch.protected): |
| 54 | + branch.remove_protection() |
| 55 | + print("Removed branch protection rules for: " + repo.name + "," + branch_name) |
| 56 | + else: |
| 57 | + print("No branch protection rules for: " + repo.name + "," + branch.name) |
54 | 58 |
|
55 | 59 | print(" ___ _ _ ______ _ ______ _ ") |
56 | 60 | print(" / _ \ | | | | | ___ \ | | | ___ \ | | ") |
|
0 commit comments