mirror of
https://github.com/sartography/spiffworkflow-backend.git
synced 2025-02-24 05:18:22 +00:00
auto git commit on save
This commit is contained in:
parent
563bdd7f3b
commit
8c5e11ca68
28
bin/git_commit_bpmn_models_repo
Executable file
28
bin/git_commit_bpmn_models_repo
Executable file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function error_handler() {
|
||||
>&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}."
|
||||
exit "$2"
|
||||
}
|
||||
trap 'error_handler ${LINENO} $?' ERR
|
||||
set -o errtrace -o errexit -o nounset -o pipefail
|
||||
|
||||
# HELP: git adds and commits the entire BPMN models directory, including all process groups
|
||||
|
||||
bpmn_models_absolute_dir="$1"
|
||||
git_commit_message="$2"
|
||||
|
||||
if [[ -z "${2:-}" ]]; then
|
||||
>&2 echo "usage: $(basename "$0") [bpmn_models_absolute_dir] [git_commit_message]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$bpmn_models_absolute_dir"
|
||||
git add .
|
||||
|
||||
# https://unix.stackexchange.com/a/155077/456630
|
||||
if [ -z "$(git status --porcelain)" ]; then
|
||||
echo "No changes to commit"
|
||||
else
|
||||
git commit -m "$git_commit_message"
|
||||
fi
|
@ -270,6 +270,10 @@ def process_model_file_update(
|
||||
)
|
||||
|
||||
SpecFileService.update_file(process_model, file_name, request_file_contents)
|
||||
git_output = GitService.commit(
|
||||
message=f"User: {g.user.username} clicked save for {process_group_id}/{process_model_id}/{file_name}"
|
||||
)
|
||||
current_app.logger.info(f"git output: {git_output}")
|
||||
return Response(json.dumps({"ok": True}), status=200, mimetype="application/json")
|
||||
|
||||
|
||||
|
@ -38,3 +38,13 @@ class GitService:
|
||||
file_contents: str = os.popen(shell_command).read()[:-1] # noqa: S605
|
||||
assert file_contents # noqa: S101
|
||||
return file_contents.encode("utf-8")
|
||||
|
||||
@staticmethod
|
||||
def commit(message: str) -> str:
|
||||
"""Commit."""
|
||||
bpmn_spec_absolute_dir = current_app.config["BPMN_SPEC_ABSOLUTE_DIR"]
|
||||
shell_command = (
|
||||
f"./bin/git_commit_bpmn_models_repo '{bpmn_spec_absolute_dir}' '{message}'"
|
||||
)
|
||||
output = os.popen(shell_command).read() # noqa: S605
|
||||
return output
|
||||
|
@ -206,7 +206,12 @@ class ProcessModelService(FileSystemService):
|
||||
os.makedirs(cat_path, exist_ok=True)
|
||||
json_path = os.path.join(cat_path, self.CAT_JSON_FILE)
|
||||
with open(json_path, "w") as cat_json:
|
||||
json.dump(self.GROUP_SCHEMA.dump(process_group), cat_json, indent=4)
|
||||
json.dump(
|
||||
self.GROUP_SCHEMA.dump(process_group),
|
||||
cat_json,
|
||||
indent=4,
|
||||
sort_keys=True,
|
||||
)
|
||||
return process_group
|
||||
|
||||
def process_group_delete(self, process_group_id: str) -> None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user