diff --git a/util/deploy.py b/util/deploy.py index dbd76c79..d004f401 100644 --- a/util/deploy.py +++ b/util/deploy.py @@ -11,21 +11,17 @@ import time # Git command fragments -CHECK_BRANCH_CMD = 'git rev-parse --verify' GET_BRANCH_CMD = '''git for-each-ref --format='%(objectname) %(refname:short)' refs/heads |\ awk "/^$(git rev-parse HEAD)/ {print \\$2}"''' GET_COMMIT_ID_CMD = 'git rev-parse HEAD' GET_COMMIT_MSG_CMD = 'git log -1 --pretty=%B' GIT_ADD_ALL_CMD = 'git add .' -GIT_CHECKOUT_CMD = 'git checkout' GIT_CHECKOUT_TAG_CMD = 'git checkout -b' GIT_COMMIT_CMD = 'git commit -m' -GIT_MERGE_SQUASH_CMD = 'git merge --squash' GIT_PUSH_CMD = 'git push' # Repo configuration ORIGIN = 'origin' -ROOT_MAIN_TAG = 'v0.6.0-beta' # Comment added to gitignore GITIGNORE_COMMENT = '# Deactivated by deploy.py' @@ -39,26 +35,15 @@ print(f'Current commit message: \n{current_msg}') # create target branch -deploy_branch = f'__deploy__{current_branch}' +deploy_branch = f'__deploy__{current_hash[0:7]}__{current_branch}' print(f'Deploy branch: {deploy_branch}\n\n') -last_deploy_hash = os.popen(f'{CHECK_BRANCH_CMD} {ORIGIN}/{deploy_branch}').read() -print(f'Last deploy hash: {last_deploy_hash} (empty if on deploy branch present)') deploy_msg = f'{current_msg}\n-----\n\nDeployed from {current_hash}' print(f'Deploy commit message:\n{deploy_msg}') -# spawn or switch to deploy branch -if last_deploy_hash == '': - # create new deploy branch - os.popen(f'{GIT_CHECKOUT_TAG_CMD} {deploy_branch} {ROOT_MAIN_TAG}') -else: - # deploy branch exists - os.popen(f'{GIT_CHECKOUT_CMD} {deploy_branch}') +# create new deploy branch +os.popen(f'{GIT_CHECKOUT_TAG_CMD} {deploy_branch} {current_branch}') time.sleep(2) -# merge feature into deploy branch -os.popen(f'{GIT_MERGE_SQUASH_CMD} {ORIGIN}/{current_branch}') -time.sleep(0.5) - # selectively deactivate gitignore to check in generated files with open('target/rtl/.gitignore', 'r', encoding='utf-8') as f: content = f.read().split('\n')[:-1]