From 34e4e4870e85bed3cda03c0b8abe71f40dcf2792 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 11 Apr 2021 11:59:41 +0800 Subject: [PATCH] build-integration-branch: retry when running into network failures Signed-off-by: Kefu Chai --- src/script/build-integration-branch | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/script/build-integration-branch b/src/script/build-integration-branch index 6bedd7d16223e..0450f6a341132 100755 --- a/src/script/build-integration-branch +++ b/src/script/build-integration-branch @@ -93,8 +93,20 @@ for pr in prs: pr_url = pr['head']['repo']['clone_url'] pr_ref = pr['head']['ref'] print(f'--- pr {pr_number} --- pulling {pr_url} branch {pr_ref}') - r = call(['git', 'pull', '--no-edit', pr_url, pr_ref]) - assert not r + while True: + r = call(['git', 'pull', '--no-edit', pr_url, pr_ref]) + if r == 0: + break + elif r == 1: + print(f'Unable to access {pr_url}, retrying..') + elif r == 128: + message = f'Unable to resolve conflict when merging PR#{pr_number}' + raise Exception(message) + else: + message = ('Exiting due to an unknown failure when pulling ' + f'PR#{pr_number}') + raise Exception(message) + print('--- done. these PRs were included:') print('\n'.join(prtext).encode('ascii', errors='ignore').decode()) print('--- perhaps you want to: make && ctest -j12 && git push ci %s' % branch) -- 2.39.5