git-info
Easily extract information about a git reference (branch, tag, commit hash, committer, commit time, commit message, version),and expose it as a JSON file, a directory, or environment variables.
Installation
dagger install github.com/vbehar/daggerverse/git-info@v0.10.0
Entrypoint
Return Type
GitInfo !
Arguments
Name | Type | Description |
---|---|---|
gitDirectory | Directory ! | directory containing the git repository can be either the worktree (including the .git subdirectory) or the .git directory iteself |
gitRef | String | git reference to use for the git commands |
gitRemoteName | String | name of the remote to use |
gitBaseContainer | Container | base container to use for git commands default to cgr.dev/chainguard/git:latest |
commitHashLength | Integer | length of the commit hash to use |
commitUserFormat | String | format of the commit user to use see https://git-scm.com/docs/git-log#_pretty_formats |
commitDateFormat | String | format of the commit time to use see https://git-scm.com/docs/git-log#_pretty_formats |
commitMessageFormat | String | format of the commit message to use see https://git-scm.com/docs/git-log#_pretty_formats |
Example
dagger -m github.com/vbehar/daggerverse/git-info@eb093e6d7e210474167957615e3f06f2bc8fd7d4 call \
--git-directory DIR_PATH
func (m *myModule) example(gitDirectory *Directory) *GitInfo {
return dag.
GitInfo(gitDirectory)
}
@function
def example(git_directory: dagger.Directory, ) -> dag.GitInfo:
return (
dag.git_info(git_directory)
)
@func()
example(gitDirectory: Directory, ): GitInfo {
return dag
.gitInfo(gitDirectory)
}
Types
GitInfo 🔗
GitInfo contains information about a git reference
ref() 🔗
git reference used for the git commands
Return Type
String !
Example
dagger -m github.com/vbehar/daggerverse/git-info@eb093e6d7e210474167957615e3f06f2bc8fd7d4 call \
--git-directory DIR_PATH ref
func (m *myModule) example(ctx context.Context, gitDirectory *Directory) string {
return dag.
GitInfo(gitDirectory).
Ref(ctx)
}
@function
async def example(git_directory: dagger.Directory, ) -> str:
return await (
dag.git_info(git_directory)
.ref()
)
@func()
async example(gitDirectory: Directory, ): Promise<string> {
return dag
.gitInfo(gitDirectory)
.ref()
}
branch() 🔗
branch of the git reference
Return Type
String !
Example
dagger -m github.com/vbehar/daggerverse/git-info@eb093e6d7e210474167957615e3f06f2bc8fd7d4 call \
--git-directory DIR_PATH branch
func (m *myModule) example(ctx context.Context, gitDirectory *Directory) string {
return dag.
GitInfo(gitDirectory).
Branch(ctx)
}
@function
async def example(git_directory: dagger.Directory, ) -> str:
return await (
dag.git_info(git_directory)
.branch()
)
@func()
async example(gitDirectory: Directory, ): Promise<string> {
return dag
.gitInfo(gitDirectory)
.branch()
}
tag() 🔗
tag of the git reference - if any
Return Type
String !
Example
dagger -m github.com/vbehar/daggerverse/git-info@eb093e6d7e210474167957615e3f06f2bc8fd7d4 call \
--git-directory DIR_PATH tag
func (m *myModule) example(ctx context.Context, gitDirectory *Directory) string {
return dag.
GitInfo(gitDirectory).
Tag(ctx)
}
@function
async def example(git_directory: dagger.Directory, ) -> str:
return await (
dag.git_info(git_directory)
.tag()
)
@func()
async example(gitDirectory: Directory, ): Promise<string> {
return dag
.gitInfo(gitDirectory)
.tag()
}
commitHash() 🔗
commit hash of the git reference
Return Type
String !
Example
dagger -m github.com/vbehar/daggerverse/git-info@eb093e6d7e210474167957615e3f06f2bc8fd7d4 call \
--git-directory DIR_PATH commit-hash
func (m *myModule) example(ctx context.Context, gitDirectory *Directory) string {
return dag.
GitInfo(gitDirectory).
CommitHash(ctx)
}
@function
async def example(git_directory: dagger.Directory, ) -> str:
return await (
dag.git_info(git_directory)
.commit_hash()
)
@func()
async example(gitDirectory: Directory, ): Promise<string> {
return dag
.gitInfo(gitDirectory)
.commitHash()
}
commitUser() 🔗
committer information
Return Type
String !
Example
dagger -m github.com/vbehar/daggerverse/git-info@eb093e6d7e210474167957615e3f06f2bc8fd7d4 call \
--git-directory DIR_PATH commit-user
func (m *myModule) example(ctx context.Context, gitDirectory *Directory) string {
return dag.
GitInfo(gitDirectory).
CommitUser(ctx)
}
@function
async def example(git_directory: dagger.Directory, ) -> str:
return await (
dag.git_info(git_directory)
.commit_user()
)
@func()
async example(gitDirectory: Directory, ): Promise<string> {
return dag
.gitInfo(gitDirectory)
.commitUser()
}
commitTime() 🔗
commit time
Return Type
String !
Example
dagger -m github.com/vbehar/daggerverse/git-info@eb093e6d7e210474167957615e3f06f2bc8fd7d4 call \
--git-directory DIR_PATH commit-time
func (m *myModule) example(ctx context.Context, gitDirectory *Directory) string {
return dag.
GitInfo(gitDirectory).
CommitTime(ctx)
}
@function
async def example(git_directory: dagger.Directory, ) -> str:
return await (
dag.git_info(git_directory)
.commit_time()
)
@func()
async example(gitDirectory: Directory, ): Promise<string> {
return dag
.gitInfo(gitDirectory)
.commitTime()
}
commitMessage() 🔗
commit message
Return Type
String !
Example
dagger -m github.com/vbehar/daggerverse/git-info@eb093e6d7e210474167957615e3f06f2bc8fd7d4 call \
--git-directory DIR_PATH commit-message
func (m *myModule) example(ctx context.Context, gitDirectory *Directory) string {
return dag.
GitInfo(gitDirectory).
CommitMessage(ctx)
}
@function
async def example(git_directory: dagger.Directory, ) -> str:
return await (
dag.git_info(git_directory)
.commit_message()
)
@func()
async example(gitDirectory: Directory, ): Promise<string> {
return dag
.gitInfo(gitDirectory)
.commitMessage()
}
version() 🔗
version of the git reference
Return Type
String !
Example
dagger -m github.com/vbehar/daggerverse/git-info@eb093e6d7e210474167957615e3f06f2bc8fd7d4 call \
--git-directory DIR_PATH version
func (m *myModule) example(ctx context.Context, gitDirectory *Directory) string {
return dag.
GitInfo(gitDirectory).
Version(ctx)
}
@function
async def example(git_directory: dagger.Directory, ) -> str:
return await (
dag.git_info(git_directory)
.version()
)
@func()
async example(gitDirectory: Directory, ): Promise<string> {
return dag
.gitInfo(gitDirectory)
.version()
}
url() 🔗
URL of the git repository
Return Type
String !
Example
dagger -m github.com/vbehar/daggerverse/git-info@eb093e6d7e210474167957615e3f06f2bc8fd7d4 call \
--git-directory DIR_PATH url
func (m *myModule) example(ctx context.Context, gitDirectory *Directory) string {
return dag.
GitInfo(gitDirectory).
Url(ctx)
}
@function
async def example(git_directory: dagger.Directory, ) -> str:
return await (
dag.git_info(git_directory)
.url()
)
@func()
async example(gitDirectory: Directory, ): Promise<string> {
return dag
.gitInfo(gitDirectory)
.url()
}
name() 🔗
Name of the git repository (last part of the URL)
Return Type
String !
Example
dagger -m github.com/vbehar/daggerverse/git-info@eb093e6d7e210474167957615e3f06f2bc8fd7d4 call \
--git-directory DIR_PATH name
func (m *myModule) example(ctx context.Context, gitDirectory *Directory) string {
return dag.
GitInfo(gitDirectory).
Name(ctx)
}
@function
async def example(git_directory: dagger.Directory, ) -> str:
return await (
dag.git_info(git_directory)
.name()
)
@func()
async example(gitDirectory: Directory, ): Promise<string> {
return dag
.gitInfo(gitDirectory)
.name()
}
json() 🔗
Json returns the JSON representation of the git info
Return Type
String !
Example
dagger -m github.com/vbehar/daggerverse/git-info@eb093e6d7e210474167957615e3f06f2bc8fd7d4 call \
--git-directory DIR_PATH json
func (m *myModule) example(ctx context.Context, gitDirectory *Directory) string {
return dag.
GitInfo(gitDirectory).
Json(ctx)
}
@function
async def example(git_directory: dagger.Directory, ) -> str:
return await (
dag.git_info(git_directory)
.json()
)
@func()
async example(gitDirectory: Directory, ): Promise<string> {
return dag
.gitInfo(gitDirectory)
.json()
}
jsonFile() 🔗
JsonFile returns a dagger file containing the JSON representation of the git info
Return Type
File !
Example
dagger -m github.com/vbehar/daggerverse/git-info@eb093e6d7e210474167957615e3f06f2bc8fd7d4 call \
--git-directory DIR_PATH json-file
func (m *myModule) example(gitDirectory *Directory) *File {
return dag.
GitInfo(gitDirectory).
JsonFile()
}
@function
def example(git_directory: dagger.Directory, ) -> dagger.File:
return (
dag.git_info(git_directory)
.json_file()
)
@func()
example(gitDirectory: Directory, ): File {
return dag
.gitInfo(gitDirectory)
.jsonFile()
}
directory() 🔗
Directory returns a dagger directory containing the git info - each field is stored in a separate file: - ref: git reference used for the git commands - branch: branch of the git reference - tag: tag of the git reference - if any - commit-hash: commit hash of the git reference - commit-user: committer information - commit-time: commit time - commit-message: commit message - version: version of the git reference - url: URL of the git repository - name: Name of the git repository (last part of the URL)
Return Type
Directory !
Example
dagger -m github.com/vbehar/daggerverse/git-info@eb093e6d7e210474167957615e3f06f2bc8fd7d4 call \
--git-directory DIR_PATH directory
func (m *myModule) example(gitDirectory *Directory) *Directory {
return dag.
GitInfo(gitDirectory).
Directory()
}
@function
def example(git_directory: dagger.Directory, ) -> dagger.Directory:
return (
dag.git_info(git_directory)
.directory()
)
@func()
example(gitDirectory: Directory, ): Directory {
return dag
.gitInfo(gitDirectory)
.directory()
}
setEnvVariablesOnContainer() 🔗
SetEnvVariablesOnContainer sets the git info as environment variables on the container: - GIT_REF: git reference used for the git commands - GIT_BRANCH: branch of the git reference - GIT_TAG: tag of the git reference - if any - GIT_COMMIT_HASH: commit hash of the git reference - GIT_COMMIT_USER: committer information - GIT_COMMIT_TIME: commit time - GIT_COMMIT_MESSAGE: commit message - GIT_VERSION: version of the git reference - GIT_URL: URL of the git repository - GIT_NAME: Name of the git repository (last part of the URL)
Return Type
Container !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
ctr | Container ! | - | No description provided |
Example
dagger -m github.com/vbehar/daggerverse/git-info@eb093e6d7e210474167957615e3f06f2bc8fd7d4 call \
--git-directory DIR_PATH set-env-variables-on-container --ctr IMAGE:TAG
func (m *myModule) example(gitDirectory *Directory, ctr *Container) *Container {
return dag.
GitInfo(gitDirectory).
SetEnvVariablesOnContainer(ctr)
}
@function
def example(git_directory: dagger.Directory, ctr: dagger.Container) -> dagger.Container:
return (
dag.git_info(git_directory)
.set_env_variables_on_container(ctr)
)
@func()
example(gitDirectory: Directory, ctr: Container): Container {
return dag
.gitInfo(gitDirectory)
.setEnvVariablesOnContainer(ctr)
}