mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
a91eace041
## Issue being fixed or feature implemented small cleanups and improvements ## What was done? pls see individual commits ## How Has This Been Tested? see https://github.com/dashpay/dash/actions/runs/4715728701/jobs/8362893373?pr=5330 ## Breaking Changes n/a ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_
77 lines
2.0 KiB
Python
Executable File
77 lines
2.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
||
# Copyright (c) 2022-2023 The Dash Core developers
|
||
# Distributed under the MIT software license, see the accompanying
|
||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||
|
||
"""
|
||
|
||
Usage:
|
||
$ ./handle_potential_conflicts.py <conflicts>
|
||
|
||
Where <conflicts> is a json string which looks like
|
||
{ pull_number: 26,
|
||
conflictPrs:
|
||
[ { number: 15,
|
||
files: [ 'testfile1', `testfile2` ],
|
||
conflicts: [ 'testfile1' ] },
|
||
...
|
||
]}
|
||
"""
|
||
|
||
import sys
|
||
import requests
|
||
|
||
# need to install via pip
|
||
import hjson
|
||
|
||
def get_label(pr_num):
|
||
return requests.get(f'https://api.github.com/repos/dashpay/dash/pulls/{pr_num}').json()['head']['label']
|
||
|
||
def main():
|
||
if len(sys.argv) != 2:
|
||
print(f'Usage: {sys.argv[0]} <conflicts>', file=sys.stderr)
|
||
sys.exit(1)
|
||
|
||
input = sys.argv[1]
|
||
print(input)
|
||
j_input = hjson.loads(input)
|
||
print(j_input)
|
||
|
||
|
||
our_pr_num = j_input['pull_number']
|
||
our_pr_label = get_label(our_pr_num)
|
||
conflictPrs = j_input['conflictPrs']
|
||
|
||
good = []
|
||
bad = []
|
||
|
||
for conflict in conflictPrs:
|
||
this_pr_num = conflict['number']
|
||
print(this_pr_num)
|
||
|
||
r = requests.get(f'https://api.github.com/repos/dashpay/dash/pulls/{this_pr_num}')
|
||
print(r.json()['head']['label'])
|
||
|
||
mergable_state = r.json()['mergeable_state']
|
||
if mergable_state == "dirty":
|
||
print(f'{this_pr_num} needs rebase. Skipping conflict check')
|
||
continue
|
||
|
||
r = requests.get(f'https://github.com/dashpay/dash/branches/pre_mergeable/{our_pr_label}...{get_label(this_pr_num)}')
|
||
if "These branches can be automatically merged." in r.text:
|
||
good.append(this_pr_num)
|
||
elif "Can’t automatically merge" in r.text:
|
||
bad.append(this_pr_num)
|
||
else:
|
||
raise Exception("not mergeable or unmergable!")
|
||
|
||
print("Not conflicting PRs: ", good)
|
||
|
||
print("Conflicting PRs: ", bad)
|
||
if len(bad) > 0:
|
||
sys.exit(1)
|
||
|
||
|
||
if __name__ == "__main__":
|
||
main()
|