summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Smith <chad.smith@canonical.com>2019-11-25 17:03:11 -0700
committerGitHub <noreply@github.com>2019-11-25 17:03:11 -0700
commit250a3f92473feeb2689f3a214e8f1b79fa419334 (patch)
tree02984b29bb7de3d25ef18e9b5b84d7ae282ff238
parentbf075cf6f9a434c5fc2bdbc52e45d339e114f64e (diff)
downloadvyos-cloud-init-250a3f92473feeb2689f3a214e8f1b79fa419334.tar.gz
vyos-cloud-init-250a3f92473feeb2689f3a214e8f1b79fa419334.zip
tools: migrate-lp-user-to-github removes repo_dir if created (#35)
To run: ./tools/migrate-lp-user-to-github LAUCHPAD_USERNAME GITHUB_USERNAME
-rwxr-xr-xtools/migrate-lp-user-to-github34
1 files changed, 23 insertions, 11 deletions
diff --git a/tools/migrate-lp-user-to-github b/tools/migrate-lp-user-to-github
index 6a498072..cbb34695 100755
--- a/tools/migrate-lp-user-to-github
+++ b/tools/migrate-lp-user-to-github
@@ -176,24 +176,34 @@ def main():
VERBOSITY = 1 if args.verbose else 0
repo_dir = args.repo_dir or PUBLISH_DIR
if not os.path.exists(repo_dir):
+ cleanup_repo_dir = True
subp(['git', 'clone',
LP_UPSTREAM_PATH_TMPL.format(launchpad_user=args.launchpad_user),
repo_dir])
+ else:
+ cleanup_repo_dir = False
+ cwd = os.getcwd()
os.chdir(repo_dir)
log("Sycing master branch with upstream")
subp(['git', 'checkout', 'master'])
subp(['git', 'pull'])
- lp_remote_name, gh_remote_name = add_lp_and_github_remotes(
- args.launchpad_user, args.github_user)
- commit_msg = COMMIT_MSG_TMPL.format(
- gh_username=args.github_user, lp_username=args.launchpad_user)
- create_migration_branch(
- MIGRATE_BRANCH_NAME, args.upstream, args.launchpad_user,
- args.github_user, commit_msg)
-
- for push_remote in (lp_remote_name, gh_remote_name):
- subp(['git', 'push', push_remote, MIGRATE_BRANCH_NAME, '--force'])
-
+ try:
+ lp_remote_name, gh_remote_name = add_lp_and_github_remotes(
+ args.launchpad_user, args.github_user)
+ commit_msg = COMMIT_MSG_TMPL.format(
+ gh_username=args.github_user, lp_username=args.launchpad_user)
+ create_migration_branch(
+ MIGRATE_BRANCH_NAME, args.upstream, args.launchpad_user,
+ args.github_user, commit_msg)
+
+ for push_remote in (lp_remote_name, gh_remote_name):
+ subp(['git', 'push', push_remote, MIGRATE_BRANCH_NAME, '--force'])
+ except Exception as e:
+ error('Failed setting up migration branches: {0}'.format(e))
+ finally:
+ os.chdir(cwd)
+ if cleanup_repo_dir and os.path.exists(repo_dir):
+ util.del_dir(repo_dir)
# Make merge request on LP
log("[launchpad] Automatically creating merge proposal using launchpadlib")
lp = Launchpad.login_with(
@@ -222,6 +232,8 @@ def main():
" click 'Create pull request' at the following URL:\n"
"{url}".format(url=GITHUB_PULL_URL.format(
github_user=args.github_user, branch=MIGRATE_BRANCH_NAME)))
+ if os.path.exists(repo_dir):
+ util.del_dir(repo_dir)
return 0