A categorical programming language
Revisão | 0c80c0279698f2fe155f39a53245cd05fa6f4e28 (tree) |
---|---|
Hora | 2024-11-13 11:24:51 |
Autor | Corbin <cds@corb...> |
Commiter | Corbin |
bk: With a flag, allow updating refs.
I was able to use this to programmatically update all of the demo
animation refs to use the new API.
@@ -232,12 +232,14 @@ def apply(hive, template, arguments, j): | ||
232 | 232 | @cli.command() |
233 | 233 | @HIVE_OPT |
234 | 234 | @click.option("-j", is_flag=True) |
235 | +@click.option("-y", is_flag=True, help="Overwrite existing refs") | |
235 | 236 | @click.option("--author", default="Unknown") |
236 | 237 | @click.option("--trail", default="") |
237 | 238 | @click.argument("name") |
238 | -def insert(hive, name, j, author, trail): | |
239 | +def insert(hive, name, j, y, author, trail): | |
239 | 240 | ref = b"refs/local/" + name.encode("utf-8") |
240 | - if ref in hive.refs: raise ValueError("Ref already in hive!") | |
241 | + if ref in hive.refs and not y: | |
242 | + raise ValueError("Ref already in hive (pass -y to override") | |
241 | 243 | if j: expr = json.load(sys.stdin) |
242 | 244 | else: expr, trail = parse(sys.stdin.read()) |
243 | 245 | author = author.encode("utf-8") |