コード例 #1
0
 /**
  * Check if specified checkout rules are supported
  *
  * @param root root for which rules are checked
  * @param rules rules to check
  * @throws VcsException rules are not supported
  */
 private void validateCheckoutRules(
     @NotNull final VcsRoot root, @NotNull final CheckoutRules rules) throws VcsException {
   if (rules.getExcludeRules().size() != 0) {
     throw new VcsException(
         "Exclude rules are not supported for agent checkout for the git ("
             + rules.getExcludeRules().size()
             + " rule(s) detected) for VCS Root '"
             + root.getName()
             + "'");
   }
   if (rules.getIncludeRules().size() > 1) {
     throw new VcsException(
         "At most one include rule is supported for agent checkout for the git ("
             + rules.getIncludeRules().size()
             + " rule(s) detected) for VCS Root '"
             + root.getName()
             + "'");
   }
   if (rules.getIncludeRules().size() == 1) {
     IncludeRule ir = rules.getIncludeRules().get(0);
     if (!".".equals(ir.getFrom()) && ir.getFrom().length() != 0) {
       throw new VcsException(
           "Agent checkout for the git supports only include rule of form '. => subdir', rule '"
               + ir.toDescriptiveString()
               + "' for VCS Root '"
               + root.getName()
               + "' is not supported");
     }
   }
 }
コード例 #2
0
ファイル: GitVcsSupport.java プロジェクト: idlsoft/git-plugin
  @NotNull
  @Override
  public Map<String, String> getCheckoutProperties(@NotNull VcsRoot root) throws VcsException {
    Map<String, String> defaults = getDefaultVcsProperties();
    Set<String> significantProps =
        setOf(
            Constants.FETCH_URL,
            Constants.SUBMODULES_CHECKOUT,
            Constants.AGENT_CLEAN_POLICY,
            Constants.AGENT_CLEAN_FILES_POLICY);
    Map<String, String> rootProperties = root.getProperties();
    Map<String, String> repositoryProperties = new HashMap<String, String>();
    for (String key : significantProps) {
      String defVal = defaults.get(key);
      String actualVal = rootProperties.get(key);
      repositoryProperties.put(key, actualVal == null ? defVal : actualVal);
    }

    // include autocrlf settings only for non-default value
    // in order to avoid clean checkout
    if ("true".equals(rootProperties.get(Constants.SERVER_SIDE_AUTO_CRLF)))
      repositoryProperties.put(
          Constants.SERVER_SIDE_AUTO_CRLF, rootProperties.get(Constants.SERVER_SIDE_AUTO_CRLF));

    return repositoryProperties;
  }
コード例 #3
0
  /**
   * Get the destination directory creating it if it is missing
   *
   * @param root VCS root
   * @param rules checkout rules
   * @param checkoutDirectory checkout directory for the build
   * @return the directory where vcs root should be checked out according to checkout rules
   * @throws VcsException if the directory could not be located or created
   */
  private File getTargetDir(
      @NotNull final VcsRoot root,
      @NotNull final CheckoutRules rules,
      @NotNull final File checkoutDirectory)
      throws VcsException {
    String path = rules.map("");
    if (path == null)
      throw new VcsException(
          "The root path could not be mapped for VCS root '" + root.getName() + "'");

    File directory =
        path.length() == 0
            ? checkoutDirectory
            : new File(checkoutDirectory, path.replace('/', File.separatorChar));
    if (!directory.exists()) {
      //noinspection ResultOfMethodCallIgnored
      directory.mkdirs();
      if (!directory.exists())
        throw new VcsException(
            "The destination directory '" + directory + "' could not be created.");
    }
    return directory;
  }
コード例 #4
0
ファイル: GitVcsSupport.java プロジェクト: idlsoft/git-plugin
 @NotNull
 public String describeVcsRoot(@NotNull VcsRoot root) {
   final String branch = root.getProperty(Constants.BRANCH_NAME);
   return root.getProperty(Constants.FETCH_URL) + "#" + (branch == null ? "master" : branch);
 }