Class GitService

java.lang.Object
org.qubership.atp.mia.service.git.GitService

@Service public class GitService extends Object
  • Constructor Details

    • GitService

      public GitService()
  • Method Details

    • checkXKubeUserRights

      public String checkXKubeUserRights(String pathToGit)
      Check whether x_kube2vcs user is present in git repository members with maintainer rights.
      Parameters:
      pathToGit - url to git
      Returns:
      empty string when success, otherwise validation error description.
    • downloadGitRepo

      public void downloadGitRepo(String repoUrl, Path toPath)
      Downloads GIT repository.
      Parameters:
      repoUrl - repository URL
      toPath - local path
    • executeGetAndParseGitInfoResponse

      public Optional<GitInfoResponse> executeGetAndParseGitInfoResponse(String urlSrc, String privateToken)
      Makes http request to git repository with config and return x_kube2vcs user info.
      Parameters:
      urlSrc - to git
      privateToken - private token for git API, need to be generated in x_kube2vcs account.
      Returns:
      parsed JSON object as GitInfoResponse.
      Throws:
      MiaException - - when git API returns error.
    • getGitEmail

      public String getGitEmail()
    • getGitEncodedUrl

      public String getGitEncodedUrl(String pathToGit)
      Retrieves url from git path.
      Parameters:
      pathToGit - url to git
      Returns:
      empty string if no success otherwise url.
    • getGitPass

      public String getGitPass()
    • getGitUser

      public String getGitUser()
    • gitClone

      public void gitClone(String repoUrl, File toPath)
      Git clone.
      Parameters:
      repoUrl - git URL
      toPath - folder to clone
    • gitCommitAndPush

      public void gitCommitAndPush(Path pathToGit, String commitMessagePrefix)
      Git commit.
      Parameters:
      pathToGit - path to GIT
    • gitPull

      public void gitPull(Path pathToGit)
      Git pull.
      Parameters:
      pathToGit - path to GIT
    • init

      @PostConstruct public void init()