git
git
Git command helpers shared across syncweaver modules.
Functions
| Name | Description |
|---|---|
| build_github_git_env | Build process-local GitHub auth headers for git-over-HTTPS commands. |
| is_full_git_sha | Check whether input is a full 40-character git commit SHA. |
| remote_ref_has_path_changes | Check whether two source commits differ for an optional subdirectory. |
| resolve_github_token | Resolve a GitHub token from explicit input, env var, or the gh CLI. |
| resolve_remote_ref_to_git_sha | Resolve a remote source ref to a full commit SHA via git ls-remote. |
| run_git | Run a git command and return stdout, raising RuntimeError on failure. |
build_github_git_env
git.build_github_git_env(github_token)Build process-local GitHub auth headers for git-over-HTTPS commands.
is_full_git_sha
git.is_full_git_sha(value)Check whether input is a full 40-character git commit SHA.
remote_ref_has_path_changes
git.remote_ref_has_path_changes(
repository,
previous_git_sha,
target_git_sha,
remote_subdir=None,
)Check whether two source commits differ for an optional subdirectory.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| repository | str | Source repository URL. | required |
| previous_git_sha | str | Previously tracked commit SHA. | required |
| target_git_sha | str | Candidate commit SHA. | required |
| remote_subdir | str | None | Optional tracked subdirectory path. | None |
Returns
| Name | Type | Description |
|---|---|---|
| bool | bool | True when relevant files changed between SHAs. |
Raises
| Name | Type | Description |
|---|---|---|
| ValueError | If repository or SHAs are missing/invalid. | |
| RuntimeError | If git operations fail. |
resolve_github_token
git.resolve_github_token(token)Resolve a GitHub token from explicit input, env var, or the gh CLI.
resolve_remote_ref_to_git_sha
git.resolve_remote_ref_to_git_sha(repository, source_ref)Resolve a remote source ref to a full commit SHA via git ls-remote.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| repository | str | Source repository URL. | required |
| source_ref | str | Source ref input (tag/branch/ref/commit SHA). | required |
Returns
| Name | Type | Description |
|---|---|---|
| str | str | Resolved full 40-character commit SHA. |
Raises
| Name | Type | Description |
|---|---|---|
| ValueError | If inputs are empty or ref cannot be resolved to a commit SHA. | |
| RuntimeError | If git ls-remote fails. |
run_git
git.run_git(args, cwd=None, env=None, redacted_values=None)Run a git command and return stdout, raising RuntimeError on failure.