2
0
mirror of https://github.com/frappe/bench.git synced 2024-09-24 13:09:01 +00:00

feat(release): option to prevent frontport

Option to prevent frontporting code to new branches, for example
v11(staging-fixes) should go into v12(develop)

Reason: To offload tasks to bot for normal releases, which can be done
without conflicts on a regular basis. However the frontporting releases
need manual intervention since merge conflicts arise.
This commit is contained in:
Ameya Shenoy 2018-11-19 17:42:28 +05:30
parent 50f97e28d0
commit 479ab08deb
No known key found for this signature in database
GPG Key ID: AC016A555657D0A3
2 changed files with 19 additions and 15 deletions

View File

@ -129,11 +129,13 @@ def backup_all_sites():
@click.option('--remote', default='upstream') @click.option('--remote', default='upstream')
@click.option('--owner', default='frappe') @click.option('--owner', default='frappe')
@click.option('--repo-name') @click.option('--repo-name')
def release(app, bump_type, from_branch, to_branch, owner, repo_name, remote): @click.option('--dont-frontport', is_flag=True, default=False, help='Front port fixes to new branches, example merging hotfix(v10) into staging-fixes(v11)')
def release(app, bump_type, from_branch, to_branch, owner, repo_name, remote, dont_frontport):
"Release app (internal to the Frappe team)" "Release app (internal to the Frappe team)"
from bench.release import release from bench.release import release
frontport = not dont_frontport
release(bench_path='.', app=app, bump_type=bump_type, from_branch=from_branch, to_branch=to_branch, release(bench_path='.', app=app, bump_type=bump_type, from_branch=from_branch, to_branch=to_branch,
remote=remote, owner=owner, repo_name=repo_name) remote=remote, owner=owner, repo_name=repo_name, frontport=frontport)
@click.command('prepare-beta-release') @click.command('prepare-beta-release')

View File

@ -22,7 +22,7 @@ github_username = None
github_password = None github_password = None
def release(bench_path, app, bump_type, from_branch='develop', to_branch='master', def release(bench_path, app, bump_type, from_branch='develop', to_branch='master',
remote='upstream', owner='frappe', repo_name=None): remote='upstream', owner='frappe', repo_name=None, frontport=True):
confirm_testing() confirm_testing()
config = get_config(bench_path) config = get_config(bench_path)
@ -38,7 +38,7 @@ def release(bench_path, app, bump_type, from_branch='develop', to_branch='master
validate(bench_path, config) validate(bench_path, config)
bump(bench_path, app, bump_type, from_branch=from_branch, to_branch=to_branch, owner=owner, bump(bench_path, app, bump_type, from_branch=from_branch, to_branch=to_branch, owner=owner,
repo_name=repo_name, remote=remote) repo_name=repo_name, remote=remote, frontport=frontport)
def validate(bench_path, config): def validate(bench_path, config):
global github_username, github_password global github_username, github_password
@ -65,7 +65,7 @@ def confirm_testing():
click.confirm('Is manual testing done?', abort = True) click.confirm('Is manual testing done?', abort = True)
click.confirm('Have you added the change log?', abort = True) click.confirm('Have you added the change log?', abort = True)
def bump(bench_path, app, bump_type, from_branch, to_branch, remote, owner, repo_name=None): def bump(bench_path, app, bump_type, from_branch, to_branch, remote, owner, repo_name=None, frontport=True):
assert bump_type in ['minor', 'major', 'patch', 'stable', 'prerelease'] assert bump_type in ['minor', 'major', 'patch', 'stable', 'prerelease']
repo_path = os.path.join(bench_path, 'apps', app) repo_path = os.path.join(bench_path, 'apps', app)
@ -85,7 +85,7 @@ def bump(bench_path, app, bump_type, from_branch, to_branch, remote, owner, repo
new_version = bump_repo(repo_path, bump_type, from_branch=from_branch, to_branch=to_branch) new_version = bump_repo(repo_path, bump_type, from_branch=from_branch, to_branch=to_branch)
commit_changes(repo_path, new_version, to_branch) commit_changes(repo_path, new_version, to_branch)
tag_name = create_release(repo_path, new_version, from_branch=from_branch, to_branch=to_branch) tag_name = create_release(repo_path, new_version, from_branch=from_branch, to_branch=to_branch, frontport=frontport)
push_release(repo_path, from_branch=from_branch, to_branch=to_branch, remote=remote) push_release(repo_path, from_branch=from_branch, to_branch=to_branch, remote=remote)
prerelease = True if 'beta' in new_version else False prerelease = True if 'beta' in new_version else False
create_github_release(repo_path, tag_name, message, remote=remote, owner=owner, repo_name=repo_name, prerelease=prerelease) create_github_release(repo_path, tag_name, message, remote=remote, owner=owner, repo_name=repo_name, prerelease=prerelease)
@ -244,13 +244,13 @@ def commit_changes(repo_path, new_version, to_branch):
repo.index.commit('bumped to version {}'.format(new_version)) repo.index.commit('bumped to version {}'.format(new_version))
def create_release(repo_path, new_version, from_branch='develop', to_branch='master'): def create_release(repo_path, new_version, from_branch='develop', to_branch='master', frontport=True):
print('creating release for version', new_version) print('creating release for version', new_version)
repo = git.Repo(repo_path) repo = git.Repo(repo_path)
g = repo.git g = repo.git
g.checkout(to_branch) g.checkout(to_branch)
try: try:
g.merge(from_branch, '--no-ff') g.merge(from_branch)
except git.exc.GitCommandError as e: except git.exc.GitCommandError as e:
handle_merge_error(e, source=from_branch, target=to_branch) handle_merge_error(e, source=from_branch, target=to_branch)
@ -263,13 +263,15 @@ def create_release(repo_path, new_version, from_branch='develop', to_branch='mas
except git.exc.GitCommandError as e: except git.exc.GitCommandError as e:
handle_merge_error(e, source=to_branch, target=from_branch) handle_merge_error(e, source=to_branch, target=from_branch)
for branch in branches_to_update[from_branch]: if frontport:
print('merging {0} into'.format(to_branch), branch) for branch in branches_to_update[from_branch]:
g.checkout(branch) print ("Front porting changes to {}".format(branch))
try: print('merging {0} into'.format(to_branch), branch)
g.merge(to_branch) g.checkout(branch)
except git.exc.GitCommandError as e: try:
handle_merge_error(e, source=to_branch, target=branch) g.merge(to_branch)
except git.exc.GitCommandError as e:
handle_merge_error(e, source=to_branch, target=branch)
return tag_name return tag_name