use the long revision when comparing git revs for webhook w/ burnettk

This commit is contained in:
jasquat 2023-09-25 10:37:08 -04:00
parent 08e7afee97
commit e260afd976
No known key found for this signature in database
2 changed files with 18 additions and 6 deletions

View File

@ -204,15 +204,21 @@ class VersionOneThree:
properties_json = copy.copy(task_definition.properties_json)
properties_json["event_definition"].pop("internal", None)
properties_json["event_definition"].pop("external", None)
something_changed = False
if "escalation_code" in properties_json["event_definition"]:
properties_json["event_definition"]["code"] = properties_json["event_definition"].pop(
"escalation_code"
)
something_changed = True
if "error_code" in properties_json["event_definition"]:
properties_json["event_definition"]["code"] = properties_json["event_definition"].pop("error_code")
task_definition.properties_json = properties_json
flag_modified(task_definition, "properties_json") # type: ignore
db.session.add(task_definition)
something_changed = True
if something_changed:
task_definition.properties_json = properties_json
flag_modified(task_definition, "properties_json") # type: ignore
db.session.add(task_definition)
def update_tasks_where_last_change_is_null(self) -> None:
task_models = TaskModel.query.filter(TaskModel.properties_json.like('%last_state_change": null%')).all() # type: ignore

View File

@ -31,11 +31,17 @@ class GitCommandError(Exception):
# TOOD: check for the existence of git and configs on bootup if publishing is enabled
class GitService:
@classmethod
def get_current_revision(cls) -> str:
def get_current_revision(cls, short_rev: bool = True) -> str:
bpmn_spec_absolute_dir = current_app.config["SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR"]
git_command = ["git", "rev-parse"]
if short_rev:
git_command.append("--short")
git_command.append("HEAD")
# The value includes a carriage return character at the end, so we don't grab the last character
with FileSystemService.cd(bpmn_spec_absolute_dir):
return cls.run_shell_command_to_get_stdout(["git", "rev-parse", "--short", "HEAD"])
return cls.run_shell_command_to_get_stdout(git_command)
@classmethod
def get_instance_file_contents_for_revision(
@ -187,7 +193,7 @@ class GitService:
if "after" not in webhook:
raise InvalidGitWebhookBodyError(f"Could not find the 'after' arg in the webhook body: {webhook}")
git_revision_before_pull = cls.get_current_revision()
git_revision_before_pull = cls.get_current_revision(short_rev=False)
git_revision_after = webhook["after"]
if git_revision_before_pull == git_revision_after:
current_app.logger.info("Skipping git pull because we already have the current git revision, git boy!")