Skip to content
Snippets Groups Projects

Refinements to allow direct commits to master, build skips with auto-merge

Merged André Anjos requested to merge refine-commit-file into master
2 files
+ 38
18
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -5,7 +5,8 @@ import os
import click
from . import bdt
from ..release import get_gitlab_instance, update_files_with_mr
from ..release import get_gitlab_instance, update_files_with_mr, \
update_files_at_master
from ..log import verbosity_option, get_logger
logger = get_logger(__name__)
@@ -14,18 +15,18 @@ logger = get_logger(__name__)
@click.command(epilog='''
Examples:
1. Replaces the README.rst file on the package bob/bob.extension, through a merge-request, using the contents of the local file with the same name:
1. Replaces the README.rst file on the package bob/bob.extension, through a direct commit to the master branch, using the contents of the local file with the same name:
$ bdt commitfile -vv bob/bob.extension README.rst
2. Replaces the README.rst file on the package beat/beat.core, specifying a commit/merge-request message:
2. Replaces the README.rst file on the package beat/beat.core, specifying a commit message:
\b
$ bdt commitfile -vv --message="[readme] Update [ci skip]" beat/beat.core README.rst
3. Replaces the file conda/meta.yaml on the package bob/bob.blitz through a merge request, specifying a commit/merge-request message, using the contents of the local file new.yaml, set merge-when-pipeline-succeeds, and the name of the branch to be creatd:
3. Replaces the file conda/meta.yaml on the package bob/bob.blitz through a merge request through a new branch called "conda-changes", specifying a commit/merge-request message, using the contents of the local file new.yaml, and setting the merge-request property "merge-when-pipeline-succeeds":
\b
$ bdt commitfile -vv bob/bob.blitz --path=conda/meta.yaml --branch=conda-changes --auto-merge new.yaml
@@ -38,8 +39,12 @@ Examples:
help='Message to set for this commit',)
@click.option('-p', '--path',
help='Which path to replace on the remote package',)
@click.option('-b', '--branch',
help='Name of the branch to create for this MR',)
@click.option('-b', '--branch', default='master',
help='Name of the branch to create for this commit. If the branch ' \
'name is not "master", then create a new branch and propose the ' \
'merge through a proper merge-request. Otherwise, the default ' \
'behaviour is to commit directly to the master branch ' \
'[default: %(default)s',)
@click.option('-a', '--auto-merge/--no-auto-merge', default=False,
help='If set, then the created merge request will be merged when ' \
'a potentially associated pipeline succeeds')
@@ -50,7 +55,7 @@ Examples:
@verbosity_option()
@bdt.raise_on_error
def commitfile(package, message, file, path, branch, auto_merge, dry_run):
"""Changes a file on a given package, directly on the master branch
"""Changes a file on a given package, directly on master or through MR
"""
if '/' not in package:
@@ -62,7 +67,7 @@ def commitfile(package, message, file, path, branch, auto_merge, dry_run):
# we lookup the gitlab package once
use_package = gl.projects.get(package)
logger.info('Found gitlab project %s (id=%d)',
logger.debug('Found gitlab project %s (id=%d)',
use_package.attributes['path_with_namespace'], use_package.id)
# if we are in a dry-run mode, let's let it be known
@@ -77,10 +82,12 @@ def commitfile(package, message, file, path, branch, auto_merge, dry_run):
contents = f.read()
components = os.path.splitext(path)[0].split(os.sep)
branch = branch or 'update-%s' % components[-1].lower()
message = message or ("%s update" % \
''.join(['[%s]' % k.lower() for k in components]))
# commit and push changes
update_files_with_mr(use_package, {path: contents}, message, branch,
auto_merge, dry_run, user_id)
if branch == 'master':
update_files_at_master(use_package, {path: contents}, message, dry_run)
else:
update_files_with_mr(use_package, {path: contents}, message, branch,
auto_merge, dry_run, user_id)
Loading