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. If the project has not yet locked to a data shape, a session submitted without all three is recorded as Gitless, and the project locks to Gitless going forward. Once a project is locked to Git, a session missing any of the three is rejected at ingestion instead: the results are not saved. See Run Rejected: Data Shape or Repository Doesn't Match the Project for the rejection message and how to resolve it. The remaining fields are optional.

See Providing Git Metadata for usage examples. A shallow clone or detached HEAD state, mentioned above as a reason to use this class, is also a common cause of the rejection: see Run Rejected: Data Shape or Repository Doesn't Match the Project.

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"));

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"));

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"));

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");

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);

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"));

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");

getBranch()

Returns: String - The branch name, 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.

getCommitSha()

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

getDefaultBranch()

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

getIsDirty()

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

getTag()

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

getUrl()

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

See Also