AxeWatcherGitInfo Class

This page is not available in the language you requested. You have been redirected to the English version of the page.
Link to this page copied to clipboard

Provide explicit Git metadata when automatic detection is unavailable or unreliable

Not for use with personal data

The AxeWatcherGitInfo class holds explicit Git metadata for an Axe Watcher test run. Pass an instance to setGitInfo() on AxeWatcherOptions to bypass automatic Git detection.

Use this class when:

  • Your tests run in a repository that is separate from the repository under test
  • The Git binary is unavailable in your CI environment
  • The repository is a shallow clone or is in a detached HEAD state

branch, commitSha, and url are the gitful fields: a session submitted without all three is recorded as gitless and saved, but Axe Developer Hub switches to the gitless session view, where branch and commit history from previous sessions will not be visible. Submitting a subsequent session with all three fields restores the gitful view. If only one or two of the three are present, Axe Watcher drops all gitful fields, records the session as gitless, and includes a warning in the response. The remaining fields are optional. See Providing Git Metadata for usage examples.

Constructor

AxeWatcherGitInfo()

Creates a new instance with all fields unset.

AxeWatcherGitInfo gitInfo = new AxeWatcherGitInfo();

Methods

setBranch(String branch)

Sets the Git branch name. Required for the test run to be linked to a branch and commit in Axe Developer Hub.

Parameters:

  • branch - Branch name, e.g. "main"

Returns:

  • AxeWatcherGitInfo - The current instance for method chaining

Example:

new AxeWatcherGitInfo().setBranch(System.getenv("GIT_BRANCH"));

setTag(String tag)

Sets the Git tag.

Parameters:

  • tag - Tag name, e.g. "v1.2.3"

Returns:

  • AxeWatcherGitInfo - The current instance for method chaining

Example:

new AxeWatcherGitInfo().setTag(System.getenv("GIT_TAG"));

setDefaultBranch(String defaultBranch)

Sets the default branch of the repository. Without this field, Axe Developer Hub cannot identify which branch is the default, so feature-branch comparisons against the default branch will not be available.

Parameters:

  • defaultBranch - Default branch name, e.g. "main"

Returns:

  • AxeWatcherGitInfo - The current instance for method chaining

Example:

new AxeWatcherGitInfo().setDefaultBranch("main");

setCommitSha(String commitSha)

Sets the commit SHA. Required for the test run to be linked to a branch and commit in Axe Developer Hub.

Parameters:

  • commitSha - Full or abbreviated commit hash, e.g. "abc1234"

Returns:

  • AxeWatcherGitInfo - The current instance for method chaining

Example:

new AxeWatcherGitInfo().setCommitSha(System.getenv("GIT_COMMIT"));

setCommitAuthor(String commitAuthor)

Sets the commit author's display name. If omitted, the author appears as unavailable in Axe Developer Hub.

Parameters:

  • commitAuthor - Author display name

Returns:

  • AxeWatcherGitInfo - The current instance for method chaining

Example:

new AxeWatcherGitInfo().setCommitAuthor(System.getenv("GIT_AUTHOR_NAME"));

setCommitEmail(String commitEmail)

Sets the commit author's email address.

Parameters:

  • commitEmail - Author email address

Returns:

  • AxeWatcherGitInfo - The current instance for method chaining

Example:

new AxeWatcherGitInfo().setCommitEmail(System.getenv("GIT_AUTHOR_EMAIL"));

setCommitMessage(String commitMessage)

Sets the full commit message. If omitted, the commit message appears as unavailable in Axe Developer Hub.

Parameters:

  • commitMessage - The full commit message

Returns:

  • AxeWatcherGitInfo - The current instance for method chaining

Example:

new AxeWatcherGitInfo().setCommitMessage(System.getenv("GIT_COMMIT_MESSAGE"));

setUrl(String url)

Sets the remote URL of the repository. Required for the test run to be linked to a branch and commit in Axe Developer Hub.

Parameters:

  • url - Remote URL, e.g. "https://github.com/org/repo"

Returns:

  • AxeWatcherGitInfo - The current instance for method chaining

Example:

new AxeWatcherGitInfo().setUrl("https://github.com/org/repo");

setIsDirty(boolean isDirty)

Sets whether the working tree has uncommitted changes. Set to true if there are uncommitted changes, or false if the working tree is clean. If you do not call this method, the working tree is reported as clean (false).

Parameters:

  • isDirty - true if there are uncommitted changes

Returns:

  • AxeWatcherGitInfo - The current instance for method chaining

Example:

new AxeWatcherGitInfo().setIsDirty(true);

getBranch()

Returns: String - The branch name, or null if not set.

getTag()

Returns: String - The tag, or null if not set.

getDefaultBranch()

Returns: String - The default branch name, or null if not set.

getCommitSha()

Returns: String - The commit SHA, or null if not set.

getCommitAuthor()

Returns: String - The commit author's display name, or null if not set.

getCommitEmail()

Returns: String - The commit author's email address, or null if not set.

getCommitMessage()

Returns: String - The commit message, or null if not set.

getUrl()

Returns: String - The repository remote URL, or null if not set.

getIsDirty()

Returns: Boolean - true if dirty, false if clean, or null if setIsDirty() was never called.

See Also