Git operations in HCL OneTest API

You can work with your project files that are in a Git repository from HCL OneTest™ API and perform Git operations such as checking out files from the remote repository and committing changes in the local repository to the remote repository. You can also set up the preferences in HCL OneTest API for Git.
You can perform the following Git operations in HCL OneTest API:
Note: The Git operations are enabled in the HCL OneTest API UI only after you open the project contained in the local repository.

Checking the status of files in repositories

You can visually ascertain the connectivity between HCL OneTest API and your project in a Git repository and check the status of the files in that project on the repositories.

Before you begin

Before you can check the status of the project files in a Git repository, certain tasks must be completed:
  • You must have set up the Git repositories.
  • The project files must exist in the local repository.

Procedure

  1. To open your project, start HCL OneTest API and then click Browse to navigate to the project in the local repository.
    Note: Ensure that you have completed the setup listed in Prerequisites.
  2. Look at the status bar for the icons that indicate connectivity to the Git repository. Use the following table to interpret the icons displayed.

    Icon

    Description

    image of the icon

    No Git repository exists that contains the project opened in HCL OneTest API. The project files exist only in the local repository.

    image of the icon

    The Git repository exists but is not connected.

    image of the icon

    The Git repository exists and is connected.

  3. Check for the status of the files in the project contained in the local and remote Git repositories from the Status bar. Use the following table to interpret the status displayed.

    Icon

    Description

    image of the icon

    The master branch in the Git repository exists but is not connected.

    image of the icon

    The master branch in the Git repository exists and is connected.

    image of the icon

    The master branch in the Git repository exists and is connected. The status of the files in the repositories is shown with numbers prefixed with colored arrows.

    The green colored arrow (image green arrow) indicates the local repository and the red colored arrow (image of red arrow) indicates the remote Git repository. Both the green and red arrows together (image of both arrows together.) indicate a file conflict state between the files in the local and files in the remote repositories.

    image of red arrow and number next to it

    The number along with the green colored arrow indicates the files on the local repository that are modified with respect to the same files on the remote Git repository.

    image of green arrow and number next to it

    The number along with the red colored arrow indicates the files on the remote Git repository that are modified with respect to the same files on the local repository.

    image of both red and green arrows and number next to it

    The number along with both the green and red colored arrows indicates the files with a potential conflict.

    A conflict is displayed when the same file has changes made by you in the local repository and has also been changed by someone else on the remote repository. You must resolve this conflict by either merging the changes or rejecting the changes in the remote version. You must resolve this conflict outside of HCL OneTest API by using the Git commands or any other method you prefer.

  4. Hover your cursor over the Git icon and numbers to view the location of the Git repository connected to HCL OneTest API displayed as a tooltip:
    image showing the tooltip with location of repository.
  5. Click the area with the Git icon and numbers, to view the details of the files in the repositories and files that are in conflict. The Git Information window is displayed as shown in the following sample image.
    image showing the Git information window.

    The details of the files in the local repository that are modified with respect to the files in the remote repository are shown in the following table.

    Status

    Description

    Local

    The details of the files in the local repository.

    Ahead

    The details of the files in the local repository that are modified with respect to their version on the remote Git repository. The files in the local repository have changes that are not committed or pushed to the remote repository.

    Behind

    The details of the files in the remote Git repository that are modified with respect to their version on the local Git repository. The files in the remote repository have changes that are not yet pulled into the local repository.

Checking status in the Test Factory or Architecture School perspective views

  1. Check for the status of the files in the project contained in the local and remote Git repositories by looking at the icons prefixed to the test asset in the Test Factory or Architecture School perspective views. Use the following table to interpret the displayed icon prefixed to the test asset.

    Icon

    Description

    image of the icon

    The file in the local repository that is changed from the file in the remote Git repository.

    For example, the icon displayed for a changed file in the Test Factory perspective is image of the icon.

    image of the icon

    The file in the remote Git repository that is changed from the file in the local repository.

    For example, the icon displayed for a changed file in the Test Factory perspective is image of the icon.

    image of the icon

    The file is in conflict means that the file has changes made by you in the local repository and the same file has also been changed by someone else on the remote repository.

    For example, the icon displayed for a changed file in the Test Factory perspective is image of the icon.

Updating a project in the repository

You can check out the project files from the remote Git repository to your local repository by using the UI option in HCL OneTest API. You can use this option when you want to use the latest version of the project files from the remote Git repository. This option performs a Git checkout of those files that have a conflict and does a Git fetch for the other files.

Before you begin

Before you can update the files in a project in a Git repository, certain tasks must be completed:
  • You must have set up the Git repositories.
  • The project files must exist in the local repository.
  • You must have opened the project from the local repository.
Tip: You can check if the repository is connected by looking at the Git icon (image of the icon) displayed in the Status bar. For interpreting the Git icons and numbers displayed, see Checking the status of files in repositories.

Procedure

  1. From the Menu, click Tools > Update Project.

    The Update Project window is displayed.

    Image of the update project with no conflict.

    The sample window shown in the following image is displayed if there are files in a conflict state in the local and remote repositories.

    Image of the update project with conflict.

    If you proceed with updating the project, the files in the local repository that are in the conflict state are overwritten by the files from the remote repository. If you want to retain the changes in your local version of the file and merge the changes from the remote file version, you must perform the merge operation outside of HCL OneTest API by using your preferred Git method.

  2. Click OK to pull the files from the remote Git repository to your local repository.
    Note: This action discards uncommitted changes in your project files and replaces them with the files in the project from the remote Git repository.

Results

The project files in your local repository are replaced with the version from the remote Git repository.

Delivering changes to the project in the Git repository

After you have made changes to the project files, you can deliver the changes in your local Git repository by using the UI option in HCL OneTest API to the project in the remote Git repository. This option performs the Git add, Git commit, and Git push operations on the files in that project to the remote Git repository.

Before you begin

Before you can deliver changes in the project files to the remote Git repository, certain tasks must be completed:
  • You must have set up the Git repositories.
  • The project files must exist in the local repository.
  • You must have opened the project from the local repository.
  • You must have made changes in the project for the files to show as changed in the HCL OneTest API UI.
Tip: You can check if the repository is connected by looking at the Git icon (image of the icon) displayed in the Status bar. For interpreting the Git icons displayed, see Checking the status of files in repositories.

Procedure

  1. To use the Menu option, complete the following steps:
    1. From the Menu, click Tools > Deliver changes. The changed files are listed as selected in the Deliver changes window as shown in the following sample image.
      Note: Using the Menu option to deliver changes selects all the files that have changed in the project. You can deselect or select the files you want to deliver by clicking the check box.
      Image of the Deliver changes window.
    2. In the Deliver changes window, enter text in the Commit Message box.
    3. Click OK.
  2. To use the Git options in the Logical View (Tree View) of the Architecture School perspective, complete the following steps:
    1. Open the Logical View in the Architecture School perspective and select the tree view.
    2. Select the test asset that contains the changed file, right-click and click Deliver changes. You can identify the changed file if it is prefixed with the icon (image of the icon). See the following example image. The changed files are listed as selected in the Deliver changes window as shown in the following example image.
      Image of the Git menu options in the logical view.
      Note: Using the Git menu option to deliver changes selects only the files under that test asset that you selected.
      Image of the deliver changes window.
    3. In the Deliver changes window, enter text in the Commit Message box.
    4. Click OK.
  3. To use the Git options in the Test Factory perspective, complete the following steps:
    1. Select the test asset that contains the changed file, right-click and click Deliver changes. You can identify the changed file if it is prefixed with the icon (image of the icon). See the following example image. The changed files are listed as selected in the Deliver changes window as shown in the following example image.
      Image of the Git menu options in the test factory view.
      Note: Using the Git menu option to deliver changes selects only the files under that test asset that you selected.
      Image of the deliver changes window.
    2. In the Deliver changes window, enter text in the Commit Message box.
    3. Click OK.
  4. To use the Git options in the Physical View of the Architecture School perspective, complete the following steps:
    1. Open the Physical View, select the test asset, right-click and click Deliver changes. You can identify the changed file if it is prefixed with the icon (image of the icon). See the following example image.
      Image of the Git options in the physical view.
      The changed files are listed as selected in the Deliver changes window as shown in the following sample image.
      Note: Using the Git menu option to deliver changes selects only the files under that test asset that you selected.
      Image of the Deliver changes window.
    2. In the Deliver changes window, enter text in the Commit Message box.
    3. Click OK.

Results

The changes you made in your project files in HCL OneTest API are pushed to the project in the remote Git repository.

Undoing changes in the local repository

You can check out the project files from the remote Git repository to your local repository by using the UI options in HCL OneTest API. Use this option when you have uncommitted changes in the project files on your local Git repository and you want to ignore those and reload the project using files from the remote Git repository.

Before you begin

Before you can update the files in a project in a Git repository, certain tasks must be completed:
  • You must have set up the Git repositories.
  • The project files must exist in the local repository.
  • You must have opened the project from the local repository.
  • You must have made changes in the project for the files to show as changed in the HCL OneTest API UI.
Tip: You can check if the repository is connected by looking at the Git icon (Image of the icon.) displayed in the Status bar. For interpreting the Git icons displayed, see Checking the status of files in repositories.

About this task

You can undo changes in your project files in the local repository by checking out the files from the remote Git repository or if the version of the project files in the remote repository has changes that you want to import into your local project.

Procedure

  1. To use the Menu option, complete the following steps:
    1. From the Menu, click Tools > Undo Changes. The changed files in the local repository are listed as selected in the Undo changes window as shown in the following sample image.
      Image of the undo changes window.
    2. In the Undo changes window, click OK.
  2. To use the Git options in the Logical View (Tree View) of the Architecture School perspective, complete the following steps:
    1. Open the Logical View in the Architecture School perspective and select the tree view.
    2. In the tree view, identify the files that are changed and uncommitted files in the project, which are prefixed with the icon (image of the icon). For example, if you have created a copy of a test and have not yet checked in the project files into the remote Git repository, the changed asset is displayed with the prefixed icon as shown in the following sample image.
      image showing the tree view in the Logical View with the changed file
    3. Select the test asset that contains the changed file, right-click and click Undo changes. The changed files are listed as selected in the Undo changes window as shown in the following sample image.
      Note: Using the Git menu option to undo changes selects only the files under that test asset that you selected.
      Image of the Undo changes window.
    4. In the Undo changes window, click OK.
  3. To use the Git options in the Test Factory perspective, complete the following steps:
    1. In the Test Factory perspective, identify the files that are changed and uncommitted files in the project, which are prefixed with the icon (image of the icon). For example, if you have created a copy of a test and have not yet checked in the project files into the remote Git repository, the changed asset is displayed with the prefixed icon as shown in the following sample image.
      image showing the test factory view with the changed file
    2. Select the test asset that contains the changed file, right-click and click Undo changes. The changed files are listed as selected in the Undo changes window as shown in the following sample image.
      Note: Using the Git menu option to undo changes selects only the files under that test asset that you selected.
      Image of the Undo changes window.
    3. In the Undo changes window, click OK.
  4. To use the Git options in the Physical View of the Architecture School perspective, complete the following steps:
    1. Open the Physical View, identify the files that are changed and uncommitted files in the project, which are prefixed with the icon (Image of the icon.). See the following example image.
      Image of the Git options in the physical view.
    2. Select the test asset that contains the changed file, right-click and click Undo changes. The changed files are listed as selected in the Undo changes window as shown in the following sample image.
      Note: Using the Git menu option to undo changes selects only the files under that test asset that you selected.
      Image of the undo changes window.
    3. In the Undo changes window, click OK.

Results

The changes you made in your local project files in HCL OneTest API are discarded and the latest version from the remote Git repository is checked out into the local repository.

Setting preferences for Git

You can set the preferences in HCL OneTest API for Git. You can specify the Git directory and workspace in the bare mode. You can specify your credentials to access the remote Git repository or you can configure the SSH settings.

Procedure

  1. From the Menu, click Project > Preferences.
  2. Click Git in the Preferences window.
    The git preferences window.
  3. To set up the Git repository in the bare mode, complete the following steps:
    1. Select the Enable bare mode check box.
    2. Enter the location of the Git repository that you want to set up as a bare directory. Alternatively, click Browse and navigate to the directory to select it.
      Note: You can use this option if you want to set up a bare Git directory without the project files. To set up a local repository, you must load the project files into the local repository by using your preferred method in Git before you open the project in HCL OneTest API.
    3. Enter the location that you want to use as the working directory or click Browse to navigate to the location.
  4. To set up your user credentials to enable access to the remote Git repository from HCL OneTest API, select the Git credentials check box. Enter your user name and password that you set for the remote Git repository in the corresponding fields.
  5. To set up the Secure Shell (SSH) communication between the client running HCL OneTest API and the server hosting Git, complete the following steps:
    1. Click the SSH settings check box.
    2. Enter the location of the Private Key that must be used to authenticate the client with the remote server. Alternatively, click Browse, navigate to the directory and select the Private Key.
    3. Enter the passphrase configured for the Private Key in the Passphrase field.
  6. Click Apply, and then click OK to apply the preferences that you set and exit from this window.
Feedback