<?xml version="1.0" encoding="UTF-8"?>
<dsl-extension kind="vcs" type="jetbrains.git" generateDslJar="true">
  <class name="GitVcsRoot">
    <description>Git [VCS root](https://www.jetbrains.com/help/teamcity/?Git)</description>
  </class>
  <params>
    <param name="url" mandatory="true">
      <description>Repository url</description>
    </param>
    <param name="push_url" dslName="pushUrl">
      <description>
        Custom repository push url. If not specified then the url specified in the url property is used for push operations.
        @see url
      </description>
    </param>
    <param name="branch">
      <description>The default branch name</description>
    </param>
    <param name="teamcity:branchSpec" dslName="branchSpec">
      <description>
        [Branch specification](https://www.jetbrains.com/help/teamcity/?Working+with+Feature+Branches#WorkingwithFeatureBranches-branchSpec)
        to use in VCS root
      </description>
    </param>
    <param name="reportTagRevisions" dslName="useTagsAsBranches" type="boolean" trueValue="true" falseValue="">
      <description>
        When enabled tags matched by branch specification will be shown in UI as regular branches.
        By default false.
      </description>
    </param>
    <param name="usernameStyle" dslName="userNameStyle" type="UserNameStyle">
      <description>
        Defines how TeamCity retrieves [VCS username](https://www.jetbrains.com/help/teamcity/?Managing+Users+and+User+Groups#ManagingUsersandUserGroups-vcsUsername)
        from git commit.
        @see UserNameStyle
      </description>
    </param>
    <param name="submoduleCheckout" type="CheckoutSubmodules" dslName="checkoutSubmodules">
      <description>
        Whether VCS root should include changes in submodules and check their sources for build.
        By default submodules are checked out.
        @see CheckoutSubmodules
      </description>
    </param>
    <param name="userForTags">
      <description>
        A username for tag/merge operations in this VCS root.
        Format: Username &lt;email>
      </description>
    </param>
    <param name="serverSideAutoCrlf" dslName="serverSideAutoCRLF" type="boolean" trueValue="true" falseValue="">
      <description>
        Whether TeamCity should convert line-endings of all text files to CRLF during server-side checkout.
        By default false.
      </description>
    </param>
    <param name="agentGitPath">
      <description>
        Custom path to git executable on the build agent machine
      </description>
    </param>
    <param name="agentCleanPolicy" type="AgentCleanPolicy">
      <description>
        Specifies when the "git clean" command should be executed in case of agent-side checkout
        @see AgentCleanPolicy
      </description>
    </param>
    <param name="agentCleanFilesPolicy" type="AgentCleanFilesPolicy">
      <description>
        Specifies which files should be removed when "git clean" command is executed during agent-side checkout.
        @see AgentCleanFilesPolicy
      </description>
    </param>
    <param name="useAlternates" dslName="useMirrors" deprecated="true" type="boolean" trueValue="true" falseValue="">
      <deprecated>
        Use checkoutPolicy parameter instead. Corresponding values are NO_MIRRORS for false and USE_MIRRORS for true (default value, can be ommitted).
      </deprecated>
      <description>
        When this option is enabled, TeamCity creates a separate clone of the repository on each agent
        and uses it in the checkout directory via git alternates. This make agent-side checkout faster.
        By default true.
      </description>
    </param>
    <param name="useAlternates" dslName="checkoutPolicy" type="AgentCheckoutPolicy">
      <description>
        Policy for checking out sources on agent
      </description>
    </param>
    <param name="authMethod" type="compound">
      <description>
        VCS Root authentication method
      </description>
      <option name="anonymous" value="ANONYMOUS">
        <description>Anonymous repository access</description>
      </option>
      <option name="password" value="PASSWORD">
        <description>Password authentication</description>
        <param name="username" dslName="userName">
          <description>Username to use, overwrites the username in the url</description>
        </param>
        <param name="secure:password" dslName="password" mandatory="true">
          <description>Password to use</description>
        </param>
      </option>
      <option name="uploadedKey" value="TEAMCITY_SSH_KEY">
        <description>
          Uploaded [SSH key](https://www.jetbrains.com/help/teamcity/?SSH+Keys+Management) with the specified name.
        </description>
        <param name="username" dslName="userName">
          <description>Username to use, overwrites the username in the url</description>
        </param>
        <param name="teamcitySshKey" dslName="uploadedKey" mandatory="true">
          <description>Name of the uploaded [SSH key](https://www.jetbrains.com/help/teamcity/?SSH+Keys+Management) to use</description>
        </param>
        <param name="secure:passphrase" dslName="passphrase">
          <description>
            Passphrase for the uploaded [SSH key](https://www.jetbrains.com/help/teamcity/?SSH+Keys+Management).
            Leave it empty if the key is not encrypted.
          </description>
        </param>
      </option>
      <option name="defaultPrivateKey" value="PRIVATE_KEY_DEFAULT">
        <description>
          Default SSH key found on the machine.
          If you use an agent-side checkout, then this key should also be available on the build agent machines.
          Often it is easier to use the uploaded SSH key.
          @see uploadedKey
        </description>
        <param name="username" dslName="userName">
          <description>Username to use, overwrites the username in the url</description>
        </param>
      </option>
      <option name="customPrivateKey" value="PRIVATE_KEY_FILE">
        <description>
          SSH key on the specified path. Supported only for server-side checkout.
          Switch to uploaded SSH key if you want to use an agent-side checkout.
          @see uploadedKey
        </description>
        <param name="username" dslName="userName">
          <description>Username to use, overwrites the username in the url</description>
        </param>
        <param name="privateKeyPath" dslName="customKeyPath" mandatory="true">
          <description>Path to the SSH key on TeamCity server machine</description>
        </param>
        <param name="secure:passphrase" dslName="passphrase">
          <description>
            Passphrase for the key. Leave it empty if the key is not encrypted.
          </description>
        </param>
      </option>
      <option name="token" value="ACCESS_TOKEN">
        <description>Authentication with a refreshable token stored in TeamCity token storage</description>
        <param name="username" dslName="userName">
          <description>Username to use with the token</description>
        </param>
        <param name="tokenId" mandatory="true">
          <description>Compound id of a token in the token storage</description>
        </param>
      </option>
    </param>
<!-- Disable until decide whether to keep these params

    <param name="oauthProviderId">
      <description>
        OAuth connection project feature ID used for providing credentials for repository
      </description>
    </param>
    <param name="tokenType" type="TokenType">
      <description>
        OAuth connection token type used for providing credentials for repository
      </description>
    </param>-->
  </params>
  <types>
    <enum name="UserNameStyle">
      <description>
        Defines how TeamCity retrieves [VCS username](https://www.jetbrains.com/help/teamcity/?Managing+Users+and+User+Groups#ManagingUsersandUserGroups-vcsUsername)
        from git commit.

        When the git config contains the following

        ```
        [user]
          name = Joe Coder
          email = joe.coder@acme.com
        ```

        then the git username in commit is `Joe Coder &lt;joe.coder@acme.com>`.

        Different options specify which part of the git commit username is used in TeamCity.
      </description>
      <option name="NAME">
        <description>Use the name part, for full name `Joe Coder &lt;joe.coder@acme.com>` it will be `Joe Coder`</description>
      </option>
      <option name="USERID">
        <description>Use part of the email before the @ sign, for full name `Joe Coder &lt;joe.coder@acme.com>` it will be `joe.coder`</description>
      </option>
      <option name="EMAIL">
        <description>Use the email part, for full name `Joe Coder &lt;joe.coder@acme.com>` it will be `joe.coder@acme.com`</description>
      </option>
      <option name="FULL">
        <description>Use full commit username, i.e. `Joe Coder &lt;joe.coder@acme.com>`</description>
      </option>
    </enum>
    <enum name="AgentCheckoutPolicy">
      <description>
        Policy for checking out sources on agent
      </description>
      <option name="AUTO">
        <description>
          Uses shallow clone for short-lived agents and mirrors for regular long-lived agents.
        </description>
      </option>
      <option name="USE_MIRRORS">
        <description>
          Creates repository mirror on the agent machine and shares it between different builds with the same fetch URL. Most optimal approach for large repositories and long-lived agents.
        </description>
      </option>
      <option name="NO_MIRRORS">
        <description>
          Performs checkout right into the checkout directory without creating a mirror. Less optimal in terms of disk usage than mirrors.
        </description>
      </option>
      <option name="SHALLOW_CLONE">
        <description>
          Uses git shallow clone to checkout build revision (--depth 1). Ideal for short-lived agents.
        </description>
      </option>
    </enum>
    <enum name="CheckoutSubmodules">
      <description>Submodules checkout mode</description>
      <option name="SUBMODULES_CHECKOUT" value="CHECKOUT">
        <description>Checkout submodules and show submodule changes in UI</description>
      </option>
      <option name="IGNORE">
        <description>Don't checkout submodules and don't show changes from submodules in UI</description>
      </option>
      <option name="NON_RECURSIVE_CHECKOUT">
        <description>Checkout submodules non-recursively</description>
      </option>
    </enum>
    <enum name="AgentCleanPolicy">
      <description>Specifies when the "git clean" command should be executed in case of agent-side checkout</description>
      <option name="NEVER">
        <description>Don't run the "git clean" command</description>
      </option>
      <option name="ALWAYS">
        <description>Run the "git clean" command before each build</description>
      </option>
      <option name="ON_BRANCH_CHANGE">
        <description>
          Run the "git clean" command if the branch in build is different comparing to the branch in the previous build on same agent
        </description>
      </option>
    </enum>
    <enum name="AgentCleanFilesPolicy">
      <description>Specifies flags for the "git clean" command during agent-side checkout and defines which files will be removed.</description>
      <option name="IGNORED_ONLY">
        <description>Will run "git clean -dfX"</description>
      </option>
      <option name="NON_IGNORED_ONLY">
        <description>Will run "git clean -df"</description>
      </option>
      <option name="ALL_UNTRACKED">
        <description>Will run "git clean -dfx"</description>
      </option>
    </enum>
<!--    <enum name="TokenType">
      <description>
        OAuth connection token type used for providing credentials for repository
      </description>
      <option name="PERMANENT" value="permanent" description="Permanent token type"/>
      <option name="REFRESHABLE" value="refreshable" description="Refreshable token type"/>
    </enum>-->
  </types>
  <examples>
    <example>
      <description>
        Defines a VCS root MyVcsRoot with authentication by an SSH key and registers it in the project and a build configuration.
      </description>
      <code>
        project {
          ...
          vcsRoot(MyVcsRoot)

          buildType{
            id = "MyBuild"
            name = "MyBuild"

            vcs {
              root(MyVcsRoot)
            }
            ...
          }
          ...
        }

        object MyVcsRoot: GitVcsRoot({
          name = "My project main repository"
          url = "&lt;repository URL>"
          branch = "refs/heads/main"
          checkoutPolicy = AgentCheckoutPolicy.USE_MIRRORS
          authMethod = uploadedKey {
            uploadedKey = "&lt;SSH key name>"
          }
        })
      </code>
    </example>
  </examples>
</dsl-extension>
