def commit(repo, files, message): """Commits outstanding changes. Commit changes to the given files into the repository. You will need to "repo push" to push up your changes to other repositories. If a list of files is omitted, all changes reported by "repo status" will be committed. """ if not message: marker = "# Files to be committed:" hint = ["", "", marker, "#"] for file in files: hint.append("# U {}".format(file)) message = click.edit("\n".join(hint)) if message is None: click.echo("Aborted!") return msg = message.split(marker)[0].rstrip() if not msg: click.echo("Aborted! Empty commit message") return else: msg = "\n".join(message) click.echo("Files to be committed: {}".format(files)) click.echo("Commit message:\n{}".format(msg))
def commit(repo, files, message): """Commits outstanding changes. Commit changes to the given files into the repository. You will need to "repo push" to push up your changes to other repositories. If a list of files is omitted, all changes reported by "repo status" will be committed. """ if not message: marker = '# Files to be committed:' hint = ['', '', marker, '#'] for file in files: hint.append('# U %s' % file) message = click.edit('\n'.join(hint)) if message is None: click.echo('Aborted!') return msg = message.split(marker)[0].rstrip() if not msg: click.echo('Aborted! Empty commit message') return else: msg = '\n'.join(message) click.echo('Files to be committed: %s' % (files,)) click.echo('Commit message:\n' + msg)
def edit(): """Opens an editor with some text in it.""" MARKER = '# Everything below is ignored\n' message = click.edit('\n\n' + MARKER) if message is not None: msg = message.split(MARKER, 1)[0].rstrip('\n') if not msg: click.echo('Empty message!') else: click.echo('Message:\n' + msg) else: click.echo('You did not enter anything!')
def edit(): """Opens an editor with some text in it.""" MARKER = "# Everything below is ignored\n" message = click.edit(f"\n\n{MARKER}") if message is not None: msg = message.split(MARKER, 1)[0].rstrip("\n") if not msg: click.echo("Empty message!") else: click.echo(f"Message:\n{msg}") else: click.echo("You did not enter anything!")
async def differ(ctx, path): """Clear the bring cache dir in the relevant locaiont (e.g. '~/.cache/bring' on Linux).""" si = SmartInput(path) content = await si.content_async() yaml = YAML() dict_content_orig = list(yaml.load_all(content)) print(dict_content_orig) new_content = click.edit(content) dict_content_new = list(yaml.load_all(new_content)) dict_diff = diff(dict_content_orig, dict_content_new) dict_diff = list(dict_diff) print(dict_diff)
def test_fast_edit(runner): result = click.edit("a\nb", editor="sed -i~ 's/$/Test/'") assert result == "aTest\nbTest\n"