aboutsummaryrefslogtreecommitdiff
path: root/gn2
diff options
context:
space:
mode:
Diffstat (limited to 'gn2')
-rw-r--r--gn2/wqflask/edit.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/gn2/wqflask/edit.py b/gn2/wqflask/edit.py
index b845fad0..0397296e 100644
--- a/gn2/wqflask/edit.py
+++ b/gn2/wqflask/edit.py
@@ -45,17 +45,22 @@ def save_dataset_metadata(
author: str, content: str, msg: str
) -> Either:
"""Save dataset metadata to git"""
-
- (__run_cmd__(f"git -C {git_dir} reset --hard origin".split(" "))
- .then(lambda _: __run_cmd__(
- f"git -C {git_dir} pull".split(" ")))
- )
-
- with Path(output).open(mode="w") as _f:
- _f.write(content)
+ def __write__():
+ try:
+ with Path(output).open(mode="w") as f_:
+ f_.write(content)
+ return Right(0)
+ except Exception as e_:
+ return Left({
+ "command": "Writing to File",
+ "error": str(e_)
+ })
return (
- __run_cmd__(f"git -C {git_dir} add .".split(" "))
+ __run_cmd__(f"git -C {git_dir} reset --hard origin".split(" "))
+ .then(lambda _: __run_cmd__(f"git -C {git_dir} pull".split(" ")))
+ .then(lambda _: __write__())
+ .then(lambda _: __run_cmd__(f"git -C {git_dir} add .".split(" ")))
.then(lambda _: __run_cmd__(
f"git -C {git_dir} commit -m".split(" ") + [
f'{msg}', f"--author='{author}'", "--no-gpg-sign"