Browse Source

when "shore bump" updates package.yaml files, it triggers an update

master
Niklas Rosenstein 1 year ago
parent
commit
82110136e8
No known key found for this signature in database GPG Key ID: 6D269B33D25F6C6
2 changed files with 19 additions and 1 deletions
  1. + 14
    - 1
      src/shore/__main__.py
  2. + 5
    - 0
      src/shore/util/git.py

+ 14
- 1
src/shore/__main__.py

@ -299,7 +299,8 @@ def checks(treat_warnings_as_errors):
@cli.command('update')
@click.option('--skip-checks', is_flag=True)
@click.option('--dry', is_flag=True)
def update(skip_checks, dry):
@click.option('--stage', is_flag=True, help='Stage changed files in Git.')
def update(skip_checks, dry, stage):
""" (Re-)render files managed shore. """
def _collect_files(subject):
@ -318,6 +319,9 @@ def update(skip_checks, dry):
if not dry:
write_to_disk(file)
if stage:
_git.add([f.name for f in files])
@cli.command('verify')
@click.option('--tag', '-t', help='Specify the tag from CI checks to match with the tag produced by shore.')
@ -497,6 +501,15 @@ def bump(**args):
with open(group_key, 'w') as fp:
fp.write(content)
if args['tag'] and version_sel_refs:
logger.warning('bump requires an update in order to automatically tag')
_cache.clear()
try:
update(['--stage'])
except SystemExit as exc:
if exc.code != 0:
raise
if args['tag']:
if any(f.mode == 'A' for f in _git.porcelain()):
logger.error('cannot tag with non-empty staging area')

+ 5
- 0
src/shore/util/git.py

@ -27,6 +27,11 @@ Branch = collections.namedtuple('Branch', 'name,current')
FileStatus = collections.namedtuple('FileStatus', 'mode,filename')
def add(files: List[str], path: str = None):
command = ['git', 'add', '--'] + files
subprocess.check_call(command, cwd=path)
def branches(path: str = None) -> List[Branch]:
command = ['git', 'branch']
results = []

Loading…
Cancel
Save