Skip to content

Commit 90621af

Browse files
git: add contains_commit
1 parent 715d6fd commit 90621af

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

misc/python/materialize/git.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,12 @@ def is_on_main_branch() -> bool:
278278
return get_branch_name() == "main"
279279

280280

281+
def contains_commit(commit_sha: str, target: str = "HEAD") -> bool:
282+
command = ["git", "merge-base", "--is-ancestor", commit_sha, target]
283+
return_code = spawn.run_and_get_return_code(command)
284+
return return_code == 0
285+
286+
281287
def get_tagged_release_version(version_type: type[VERSION_TYPE]) -> VERSION_TYPE | None:
282288
"""
283289
This returns the release version if exactly this commit is tagged.

0 commit comments

Comments
 (0)