tooling(restep): postmanual arg
This commit is contained in:
parent
9d44c2f928
commit
d3dfd3fc8b
1 changed files with 34 additions and 22 deletions
56
sync.py
56
sync.py
|
@ -404,6 +404,30 @@ def err(message: str, exc: Exception | None = None) -> None:
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def add_and_commit(
|
||||||
|
cmd: Callable[[str], Callable[[], CompletedProcess]],
|
||||||
|
) -> CompletedProcess:
|
||||||
|
if GH_ACT:
|
||||||
|
cp = cmd("git config user.name 'github-actions[bot]'")()
|
||||||
|
if cp.returncode != 0:
|
||||||
|
return cp
|
||||||
|
|
||||||
|
cp = cmd(
|
||||||
|
"git config user.email 'github-actions[bot]@users.noreply.github.com'"
|
||||||
|
)()
|
||||||
|
if cp.returncode != 0:
|
||||||
|
return cp
|
||||||
|
|
||||||
|
cp = cmd("git add -A")()
|
||||||
|
if cp.returncode != 0:
|
||||||
|
return cp
|
||||||
|
|
||||||
|
return cmd(
|
||||||
|
"git commit --allow-empty "
|
||||||
|
f'-am "{COMMIT_MESSAGE}" --author="{COMMIT_AUTHOR}"',
|
||||||
|
)()
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
"""
|
"""
|
||||||
command line entry point
|
command line entry point
|
||||||
|
@ -583,30 +607,9 @@ def main() -> None:
|
||||||
func=lambda: rewrite_gitattributes(Path(dir_temp)),
|
func=lambda: rewrite_gitattributes(Path(dir_temp)),
|
||||||
)
|
)
|
||||||
|
|
||||||
def add_and_commit() -> CompletedProcess:
|
|
||||||
if GH_ACT:
|
|
||||||
cp = cmd("git config user.name 'github-actions[bot]'")()
|
|
||||||
if cp.returncode != 0:
|
|
||||||
return cp
|
|
||||||
|
|
||||||
cp = cmd(
|
|
||||||
"git config user.email 'github-actions[bot]@users.noreply.github.com'"
|
|
||||||
)()
|
|
||||||
if cp.returncode != 0:
|
|
||||||
return cp
|
|
||||||
|
|
||||||
cp = cmd("git add -A")()
|
|
||||||
if cp.returncode != 0:
|
|
||||||
return cp
|
|
||||||
|
|
||||||
return cmd(
|
|
||||||
"git commit --allow-empty "
|
|
||||||
f'-am "{COMMIT_MESSAGE}" --author="{COMMIT_AUTHOR}"',
|
|
||||||
)()
|
|
||||||
|
|
||||||
step(
|
step(
|
||||||
desc="9 fin | commit",
|
desc="9 fin | commit",
|
||||||
func=add_and_commit,
|
func=lambda: add_and_commit(cmd),
|
||||||
)
|
)
|
||||||
|
|
||||||
if r.get("remote/github") is None:
|
if r.get("remote/github") is None:
|
||||||
|
@ -637,4 +640,13 @@ def main() -> None:
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
if "--postmanual" in argv:
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
|
_dir = Path.cwd()
|
||||||
|
print(f"rewriting and commiting in '{_dir}' (3 second confirmation delay)")
|
||||||
|
sleep(3.0)
|
||||||
|
rewrite_gitattributes(_dir)
|
||||||
|
add_and_commit(lambda x: lambda: run(x, cwd=_dir))
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
Reference in a new issue