git
This module has been generated via dagger init and serves as a reference tobasic module structure as you get started with Dagger.
Two functions have been pre-created. You can modify, delete, or add to them,
as needed. They demonstrate usage of arguments and return types using simple
echo and grep commands. The functions can be called from the dagger CLI or
from one of the SDKs.
The first line in this comment block is a short description line and the
rest is a long description with more detail on the module's purpose or usage,
if appropriate. All modules should have a short description.
Installation
dagger install github.com/riftonix/daggerverse/modules/git@39548e7a809a9189ef2da6709674f8981b5c61faEntrypoint
Return Type
Git !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory | - | Git repository directory (must include .git) |
| imageRegistry | String | "docker.io" | Git image registry |
| imageRepository | String | "alpine/git" | Git image repositroy |
| imageTag | String | "2.52.0" | Git image tag |
| userId | String | "65532" | Git image user |
Example
dagger -m github.com/riftonix/daggerverse/modules/git@39548e7a809a9189ef2da6709674f8981b5c61fa call \
func (m *MyModule) Example() *dagger.Git {
return dag.
Git()
}@function
def example() -> dagger.Git:
return (
dag.git()
)@func()
example(): Git {
return dag
.git()
}Types
Git 🔗
container() 🔗
Creates container with configured git
Return Type
Container ! Example
dagger -m github.com/riftonix/daggerverse/modules/git@39548e7a809a9189ef2da6709674f8981b5c61fa call \
containerfunc (m *MyModule) Example() *dagger.Container {
return dag.
Git().
Container()
}@function
def example() -> dagger.Container:
return (
dag.git()
.container()
)@func()
example(): Container {
return dag
.git()
.container()
}ensureRef() 🔗
Resolve a ref or fail with a clear missing-ref error.
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| ref | String ! | - | Git ref or SHA to resolve |
Example
dagger -m github.com/riftonix/daggerverse/modules/git@39548e7a809a9189ef2da6709674f8981b5c61fa call \
ensure-ref --ref stringfunc (m *MyModule) Example(ctx context.Context, ref string) string {
return dag.
Git().
EnsureRef(ctx, ref)
}@function
async def example(ref: str) -> str:
return await (
dag.git()
.ensure_ref(ref)
)@func()
async example(ref: string): Promise<string> {
return dag
.git()
.ensureRef(ref)
}getChangedDirs() 🔗
Return unique changed directories between two refs.
Return Type
[String ! ] !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| baseRef | String ! | - | Base Git ref or SHA |
| headRef | String ! | - | Head Git ref or SHA |
| paths | [String ! ] | null | Optional path filters relative to the repository root |
| depth | Integer ! | 1 | Directory depth to return |
| diffFilter | String ! | "ACMRTUXB" | Git diff-filter status letters |
Example
dagger -m github.com/riftonix/daggerverse/modules/git@39548e7a809a9189ef2da6709674f8981b5c61fa call \
get-changed-dirs --base-ref string --head-ref string --depth integer --diff-filter stringfunc (m *MyModule) Example(ctx context.Context, baseRef string, headRef string, depth int, diffFilter string) []string {
return dag.
Git().
GetChangedDirs(ctx, baseRef, headRef, depth, diffFilter)
}@function
async def example(base_ref: str, head_ref: str, depth: int, diff_filter: str) -> List[str]:
return await (
dag.git()
.get_changed_dirs(base_ref, head_ref, depth, diff_filter)
)@func()
async example(baseRef: string, headRef: string, depth: number, diffFilter: string): Promise<string[]> {
return dag
.git()
.getChangedDirs(baseRef, headRef, depth, diffFilter)
}getChangedFiles() 🔗
Return changed file paths between two refs.
Return Type
[String ! ] !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| baseRef | String ! | - | Base Git ref or SHA |
| headRef | String ! | - | Head Git ref or SHA |
| paths | [String ! ] | null | Optional path filters relative to the repository root |
| diffFilter | String ! | "ACMRTUXB" | Git diff-filter status letters |
Example
dagger -m github.com/riftonix/daggerverse/modules/git@39548e7a809a9189ef2da6709674f8981b5c61fa call \
get-changed-files --base-ref string --head-ref string --diff-filter stringfunc (m *MyModule) Example(ctx context.Context, baseRef string, headRef string, diffFilter string) []string {
return dag.
Git().
GetChangedFiles(ctx, baseRef, headRef, diffFilter)
}@function
async def example(base_ref: str, head_ref: str, diff_filter: str) -> List[str]:
return await (
dag.git()
.get_changed_files(base_ref, head_ref, diff_filter)
)@func()
async example(baseRef: string, headRef: string, diffFilter: string): Promise<string[]> {
return dag
.git()
.getChangedFiles(baseRef, headRef, diffFilter)
}getChangedPaths() 🔗
Return changed paths inside diff_path between target_branch and HEAD
Return Type
[String ! ] !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| targetBranch | String ! | "master" | Target branch or ref to diff against |
| diffPath | String | "." | Path to scope the diff (relative to repo root) |
Example
dagger -m github.com/riftonix/daggerverse/modules/git@39548e7a809a9189ef2da6709674f8981b5c61fa call \
get-changed-paths --target-branch stringfunc (m *MyModule) Example(ctx context.Context, targetBranch string) []string {
return dag.
Git().
GetChangedPaths(ctx, targetBranch)
}@function
async def example(target_branch: str) -> List[str]:
return await (
dag.git()
.get_changed_paths(target_branch)
)@func()
async example(targetBranch: string): Promise<string[]> {
return dag
.git()
.getChangedPaths(targetBranch)
}getMergeBase() 🔗
Return the merge-base commit shared by two refs.
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| baseRef | String ! | - | Base Git ref or SHA |
| headRef | String ! | - | Head Git ref or SHA |
Example
dagger -m github.com/riftonix/daggerverse/modules/git@39548e7a809a9189ef2da6709674f8981b5c61fa call \
get-merge-base --base-ref string --head-ref stringfunc (m *MyModule) Example(ctx context.Context, baseRef string, headRef string) string {
return dag.
Git().
GetMergeBase(ctx, baseRef, headRef)
}@function
async def example(base_ref: str, head_ref: str) -> str:
return await (
dag.git()
.get_merge_base(base_ref, head_ref)
)@func()
async example(baseRef: string, headRef: string): Promise<string> {
return dag
.git()
.getMergeBase(baseRef, headRef)
}getShortCommitSha() 🔗
Return short commit SHA for HEAD
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| length | Integer | 8 | Length of the short SHA |
Example
dagger -m github.com/riftonix/daggerverse/modules/git@39548e7a809a9189ef2da6709674f8981b5c61fa call \
get-short-commit-shafunc (m *MyModule) Example(ctx context.Context) string {
return dag.
Git().
GetShortCommitSha(ctx)
}@function
async def example() -> str:
return await (
dag.git()
.get_short_commit_sha()
)@func()
async example(): Promise<string> {
return dag
.git()
.getShortCommitSha()
}getTags() 🔗
Return tags in the repository, optionally filtered by glob pattern.
Return Type
[String ! ] !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| pattern | String ! | "*" | Optional tag filter pattern (glob) |
Example
dagger -m github.com/riftonix/daggerverse/modules/git@39548e7a809a9189ef2da6709674f8981b5c61fa call \
get-tags --pattern stringfunc (m *MyModule) Example(ctx context.Context, pattern string) []string {
return dag.
Git().
GetTags(ctx, pattern)
}@function
async def example(pattern: str) -> List[str]:
return await (
dag.git()
.get_tags(pattern)
)@func()
async example(pattern: string): Promise<string[]> {
return dag
.git()
.getTags(pattern)
}getTagsPointingAt() 🔗
Fetch tags and return tags that point at a ref.
Return Type
[String ! ] !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| ref | String ! | "HEAD" | Git ref to inspect |
| remote | String ! | "origin" | Remote name to fetch tags from |
Example
dagger -m github.com/riftonix/daggerverse/modules/git@39548e7a809a9189ef2da6709674f8981b5c61fa call \
get-tags-pointing-at --ref string --remote stringfunc (m *MyModule) Example(ctx context.Context, ref string, remote string) []string {
return dag.
Git().
GetTagsPointingAt(ctx, ref, remote)
}@function
async def example(ref: str, remote: str) -> List[str]:
return await (
dag.git()
.get_tags_pointing_at(ref, remote)
)@func()
async example(ref: string, remote: string): Promise<string[]> {
return dag
.git()
.getTagsPointingAt(ref, remote)
}hasChanges() 🔗
Return whether any files changed between two refs.
Return Type
Boolean !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| baseRef | String ! | - | Base Git ref or SHA |
| headRef | String ! | - | Head Git ref or SHA |
| paths | [String ! ] | null | Optional path filters relative to the repository root |
| diffFilter | String ! | "ACMRTUXB" | Git diff-filter status letters |
Example
dagger -m github.com/riftonix/daggerverse/modules/git@39548e7a809a9189ef2da6709674f8981b5c61fa call \
has-changes --base-ref string --head-ref string --diff-filter stringfunc (m *MyModule) Example(ctx context.Context, baseRef string, headRef string, diffFilter string) bool {
return dag.
Git().
HasChanges(ctx, baseRef, headRef, diffFilter)
}@function
async def example(base_ref: str, head_ref: str, diff_filter: str) -> bool:
return await (
dag.git()
.has_changes(base_ref, head_ref, diff_filter)
)@func()
async example(baseRef: string, headRef: string, diffFilter: string): Promise<boolean> {
return dag
.git()
.hasChanges(baseRef, headRef, diffFilter)
}listTags() 🔗
Compatibility wrapper for get_tags.
Return Type
[String ! ] !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| pattern | String ! | "*" | Optional tag filter pattern (glob) |
Example
dagger -m github.com/riftonix/daggerverse/modules/git@39548e7a809a9189ef2da6709674f8981b5c61fa call \
list-tags --pattern stringfunc (m *MyModule) Example(ctx context.Context, pattern string) []string {
return dag.
Git().
ListTags(ctx, pattern)
}@function
async def example(pattern: str) -> List[str]:
return await (
dag.git()
.list_tags(pattern)
)@func()
async example(pattern: string): Promise<string[]> {
return dag
.git()
.listTags(pattern)
}withFetchedRefs() 🔗
Fetch refs from remote and keep them available for later Git calls.
Return Type
Git !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| remote | String ! | "origin" | Remote name to fetch refs from |
| refspecs | [String ! ] | null | Optional refspecs to fetch |
| depth | Integer | null | Optional shallow fetch depth |
| prune | Boolean | false | Prune deleted remote-tracking refs |
Example
dagger -m github.com/riftonix/daggerverse/modules/git@39548e7a809a9189ef2da6709674f8981b5c61fa call \
with-fetched-refs --remote stringfunc (m *MyModule) Example(remote string) *dagger.Git {
return dag.
Git().
WithFetchedRefs(remote)
}@function
def example(remote: str) -> dagger.Git:
return (
dag.git()
.with_fetched_refs(remote)
)@func()
example(remote: string): Git {
return dag
.git()
.withFetchedRefs(remote)
}withFetchedTags() 🔗
Fetch tags from remote.
Return Type
Git !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| remote | String ! | "origin" | Remote name to fetch tags from |
| prune | Boolean | false | Prune deleted tags |
Example
dagger -m github.com/riftonix/daggerverse/modules/git@39548e7a809a9189ef2da6709674f8981b5c61fa call \
with-fetched-tags --remote stringfunc (m *MyModule) Example(remote string) *dagger.Git {
return dag.
Git().
WithFetchedTags(remote)
}@function
def example(remote: str) -> dagger.Git:
return (
dag.git()
.with_fetched_tags(remote)
)@func()
example(remote: string): Git {
return dag
.git()
.withFetchedTags(remote)
}withSshPrivateKey() 🔗
Add ssh private key to container
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | File ! | - | Private key file |
Example
dagger -m github.com/riftonix/daggerverse/modules/git@39548e7a809a9189ef2da6709674f8981b5c61fa call \
with-ssh-private-key --source file:pathfunc (m *MyModule) Example(ctx context.Context, source *dagger.File) string {
return dag.
Git().
WithSshPrivateKey(ctx, source)
}@function
async def example(source: dagger.File) -> str:
return await (
dag.git()
.with_ssh_private_key(source)
)@func()
async example(source: File): Promise<string> {
return dag
.git()
.withSshPrivateKey(source)
}withUnshallow() 🔗
Ensure a shallow repository has full history for later Git calls.
Return Type
Git !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| remote | String ! | "origin" | Remote name to fetch full history from |
Example
dagger -m github.com/riftonix/daggerverse/modules/git@39548e7a809a9189ef2da6709674f8981b5c61fa call \
with-unshallow --remote stringfunc (m *MyModule) Example(remote string) *dagger.Git {
return dag.
Git().
WithUnshallow(remote)
}@function
def example(remote: str) -> dagger.Git:
return (
dag.git()
.with_unshallow(remote)
)@func()
example(remote: string): Git {
return dag
.git()
.withUnshallow(remote)
}