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.
(repo, files, message)
| 124 | @click.argument("files", nargs=-1, type=click.Path()) |
| 125 | @pass_repo |
| 126 | def commit(repo, files, message): |
| 127 | """Commits outstanding changes. |
| 128 | |
| 129 | Commit changes to the given files into the repository. You will need to |
| 130 | "repo push" to push up your changes to other repositories. |
| 131 | |
| 132 | If a list of files is omitted, all changes reported by "repo status" |
| 133 | will be committed. |
| 134 | """ |
| 135 | if not message: |
| 136 | marker = "# Files to be committed:" |
| 137 | hint = ["", "", marker, "#"] |
| 138 | for file in files: |
| 139 | hint.append(f"# U {file}") |
| 140 | message = click.edit("\n".join(hint)) |
| 141 | if message is None: |
| 142 | click.echo("Aborted!") |
| 143 | return |
| 144 | msg = message.split(marker)[0].rstrip() |
| 145 | if not msg: |
| 146 | click.echo("Aborted! Empty commit message") |
| 147 | return |
| 148 | else: |
| 149 | msg = "\n".join(message) |
| 150 | click.echo(f"Files to be committed: {files}") |
| 151 | click.echo(f"Commit message:\n{msg}") |
| 152 | |
| 153 | |
| 154 | @cli.command(short_help="Copies files.") |