update.py: allow to disable autocommit (#119182)

This commit is contained in:
Matthieu Coudron 2021-04-22 03:21:36 +02:00 committed by GitHub
parent 1d0542c07b
commit 3eb8f4d15c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -460,6 +460,10 @@ def parse_args(editor: Editor):
default=30, default=30,
help="Number of concurrent processes to spawn.", help="Number of concurrent processes to spawn.",
) )
parser.add_argument(
"--no-commit", "-n", action="store_true", default=False,
help="Whether to autocommit changes"
)
return parser.parse_args() return parser.parse_args()
@ -504,24 +508,30 @@ def update_plugins(editor: Editor):
redirects = update() redirects = update()
rewrite_input(args.input_file, editor.deprecated, redirects) rewrite_input(args.input_file, editor.deprecated, redirects)
commit(nixpkgs_repo, f"{editor.name}Plugins: update", [args.outfile])
autocommit = not args.no_commit
if autocommit:
commit(nixpkgs_repo, f"{editor.name}Plugins: update", [args.outfile])
if redirects: if redirects:
update() update()
commit( if autocommit:
nixpkgs_repo, commit(
f"{editor.name}Plugins: resolve github repository redirects", nixpkgs_repo,
[args.outfile, args.input_file, editor.deprecated], f"{editor.name}Plugins: resolve github repository redirects",
) [args.outfile, args.input_file, editor.deprecated],
)
for plugin_line in args.add_plugins: for plugin_line in args.add_plugins:
rewrite_input(args.input_file, editor.deprecated, append=(plugin_line + "\n",)) rewrite_input(args.input_file, editor.deprecated, append=(plugin_line + "\n",))
update() update()
plugin = fetch_plugin_from_pluginline(plugin_line) plugin = fetch_plugin_from_pluginline(plugin_line)
commit( if autocommit:
nixpkgs_repo, commit(
"{editor}Plugins.{name}: init at {version}".format( nixpkgs_repo,
editor=editor.name, name=plugin.normalized_name, version=plugin.version "{editor}Plugins.{name}: init at {version}".format(
), editor=editor.name, name=plugin.normalized_name, version=plugin.version
[args.outfile, args.input_file], ),
) [args.outfile, args.input_file],
)