Exemplo n.º 1
0
  private boolean isExceedThreashold(Date date) {

    Days daysBetweenCreationTimeAndNow = Days.daysBetween(new DateTime(date), DateTime.now());

    return daysBetweenCreationTimeAndNow.getDays()
        >= Integer.parseInt(VerigreenNeededLogic.VerigreenMap.get("daysThreashold"));
  }
Exemplo n.º 2
0
 @Override
 public void execute(JobExecutionContext context) throws JobExecutionException {
   VerigreenLogger.get()
       .log(
           getClass().getName(),
           RuntimeUtils.getCurrentMethodName(),
           String.format(
               "Branch Cleaner is running, deleting branches %s days old...",
               VerigreenNeededLogic.VerigreenMap.get("branchCleanDaysThreashold")));
   deleteBranches();
 }
Exemplo n.º 3
0
  @Override
  public void execute(JobExecutionContext arg0) throws JobExecutionException {

    VerigreenLogger.get()
        .log(
            getClass().getName(),
            RuntimeUtils.getCurrentMethodName(),
            String.format(
                "Cache Cleaner is running, deleting items %s days old...",
                VerigreenNeededLogic.VerigreenMap.get("daysThreashold")));
    deleteCommitItems();
  }
Exemplo n.º 4
0
  private List<String> branchesToBeDelete(List<String> branchesList) {
    List<String> result = new ArrayList<>();
    Repository repo = null;
    Map<String, List<String>> branchesMap = new HashMap<>();
    for (String branch : branchesList) {
      List<String> values = null;
      if (!branchesMap.containsKey(branch.subSequence(0, 10))) {
        values = new ArrayList<>();
        values.add(branch);
        branchesMap.put(branch.subSequence(0, 10).toString(), values);
      } else if (!branchesMap.get(branch.subSequence(0, 10)).contains(branch)) {
        values = branchesMap.get(branch.subSequence(0, 10));
        values.add(branch);
        branchesMap.put(branch.subSequence(0, 10).toString(), values);
      }
    }
    List<CommitItem> allBranches = CollectorApi.getCommitItemContainer().getAll();
    for (CommitItem branch : allBranches) {
      if (branchesMap.containsKey(branch.getBranchDescriptor().getNewBranch().subSequence(0, 10))) {
        branchesMap.remove(branch.getBranchDescriptor().getNewBranch().subSequence(0, 10));
      }
    }
    for (String key : branchesMap.keySet()) {
      result.addAll(branchesMap.get(key));
    }

    try {
      repo =
          new FileRepository(VerigreenNeededLogic.properties.getProperty("git.repositoryLocation"));
      if (result.contains(repo.getBranch())) {
        _jgit.checkout(VerigreenNeededLogic.VerigreenMap.get("_protectedBranches"), false, false);
      }
    } catch (IOException e) {
      VerigreenLogger.get()
          .error(
              getClass().getName(),
              RuntimeUtils.getCurrentMethodName(),
              String.format(
                  "Failed creating git repository for path [%s]",
                  VerigreenNeededLogic.properties.getProperty("git.repositoryLocation")),
              e);
    }

    return result;
  }
Exemplo n.º 5
0
 public void set_daysThreashold(int _daysThreashold) {
   VerigreenNeededLogic.VerigreenMap.put("daysThreashold", String.valueOf(_daysThreashold));
 }
Exemplo n.º 6
0
 public void setbranchCleanDaysThreashold(int branchCleanDaysThreashold) {
   VerigreenNeededLogic.VerigreenMap.put(
       "branchCleanDaysThreashold", String.valueOf(branchCleanDaysThreashold));
 }