Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(release): option to prevent frontport #749

Merged
merged 1 commit into from
Nov 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions bench/commands/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,13 @@ def backup_all_sites():
@click.option('--remote', default='upstream')
@click.option('--owner', default='frappe')
@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)"
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,
remote=remote, owner=owner, repo_name=repo_name)
remote=remote, owner=owner, repo_name=repo_name, frontport=frontport)


@click.command('prepare-beta-release')
Expand Down
28 changes: 15 additions & 13 deletions bench/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
github_password = None

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()
config = get_config(bench_path)
Expand All @@ -38,7 +38,7 @@ def release(bench_path, app, bump_type, from_branch='develop', to_branch='master
validate(bench_path, config)

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):
global github_username, github_password
Expand All @@ -65,7 +65,7 @@ def confirm_testing():
click.confirm('Is manual testing done?', 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']

repo_path = os.path.join(bench_path, 'apps', app)
Expand All @@ -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)
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)
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)
Expand Down Expand Up @@ -244,13 +244,13 @@ def commit_changes(repo_path, new_version, to_branch):

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)
repo = git.Repo(repo_path)
g = repo.git
g.checkout(to_branch)
try:
g.merge(from_branch, '--no-ff')
g.merge(from_branch)
except git.exc.GitCommandError as e:
handle_merge_error(e, source=from_branch, target=to_branch)

Expand All @@ -263,13 +263,15 @@ def create_release(repo_path, new_version, from_branch='develop', to_branch='mas
except git.exc.GitCommandError as e:
handle_merge_error(e, source=to_branch, target=from_branch)

for branch in branches_to_update[from_branch]:
print('merging {0} into'.format(to_branch), branch)
g.checkout(branch)
try:
g.merge(to_branch)
except git.exc.GitCommandError as e:
handle_merge_error(e, source=to_branch, target=branch)
if frontport:
for branch in branches_to_update[from_branch]:
print ("Front porting changes to {}".format(branch))
print('merging {0} into'.format(to_branch), branch)
g.checkout(branch)
try:
g.merge(to_branch)
except git.exc.GitCommandError as e:
handle_merge_error(e, source=to_branch, target=branch)

return tag_name

Expand Down