flake/diff-plugins: allow specifying HEAD commit

This commit is contained in:
Matt Sturgeon 2025-06-27 12:35:35 +01:00
parent 01a861f669
commit ee0f56f4f8

View file

@ -14,11 +14,20 @@ def main():
parser = ArgumentParser(description="Compare nixvim plugins with another revision") parser = ArgumentParser(description="Compare nixvim plugins with another revision")
parser.add_argument( parser.add_argument(
"flakeref", "base_flakeref",
metavar="old", metavar="before",
help="the commit or flakeref to compare against", help="the commit or flakeref to compare against",
type=flakeref, type=flakeref,
) )
parser.add_argument(
"head_flakeref",
metavar="after",
help="the commit or flakeref to compare to (default .)",
type=flakeref,
nargs="?",
default=".",
const=".",
)
parser.add_argument( parser.add_argument(
"--compact", "--compact",
"-c", "-c",
@ -27,8 +36,8 @@ def main():
) )
args = parser.parse_args() args = parser.parse_args()
after_plugins = list_plugins(".") before_plugins = list_plugins(args.base_flakeref)
before_plugins = list_plugins(args.flakeref) after_plugins = list_plugins(args.head_flakeref)
print( print(
json.dumps( json.dumps(
diff(before_plugins, after_plugins), diff(before_plugins, after_plugins),
@ -51,7 +60,9 @@ def flakeref(arg):
repo_rxp = re.compile( repo_rxp = re.compile(
r"^(?P<protocol>[^:/]+:)?(?P<repo>(:?[^/]+)/(:?[^/]+))(?P<sha>/[A-Fa-f0-9]{6,40})?$" r"^(?P<protocol>[^:/]+:)?(?P<repo>(:?[^/]+)/(:?[^/]+))(?P<sha>/[A-Fa-f0-9]{6,40})?$"
) )
if sha_rxp.match(arg): if arg.startswith("."):
return arg
elif sha_rxp.match(arg):
return f"{default_protocol}{default_repo}/{arg}" return f"{default_protocol}{default_repo}/{arg}"
elif m := repo_rxp.match(arg): elif m := repo_rxp.match(arg):
protocol = m.group("protocol") or default_protocol protocol = m.group("protocol") or default_protocol