The import operation is performed using a commit, which allows it to integrate with both pre-commit and post-commit hooks. However, in pre-commit hooks, it is not possible to iterate over the objects introduced as part of the import.
Options I tried:
diff_refs(repository_id, left_reference_id, right_reference_id, ..): This returns an object-wise diff between left_reference_id and right_reference_id. However, in the pre-commit event, the commit ID for the import is not available.
A potential quick fix would be to modify the event to also pass the commit ID. However, this would introduce a discrepancy in the pre-commit event between Commit and Import operations, which may not be ideal since a commit does not exist before it is actually created.
diff_branch(repository_id, branch_id, ..): This returns an object-wise diff of uncommitted changes on branch_id. However, unlike with the Commit operation, there are no uncommitted objects in the branch when using Import.
The import operation is performed using a commit, which allows it to integrate with both
pre-commit
andpost-commit
hooks. However, inpre-commit
hooks, it is not possible to iterate over the objects introduced as part of the import.Options I tried:
diff_refs(repository_id, left_reference_id, right_reference_id, ..)
: This returns an object-wise diff betweenleft_reference_id
andright_reference_id
. However, in thepre-commit
event, the commit ID for the import is not available.pre-commit
event betweenCommit
andImport
operations, which may not be ideal since a commit does not exist before it is actually created.diff_branch(repository_id, branch_id, ..)
: This returns an object-wise diff of uncommitted changes onbranch_id
. However, unlike with theCommit
operation, there are no uncommitted objects in the branch when using Import.