Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.StoredConfig


  public synchronized TicketLabel createLabel(RepositoryModel repository, String label, String createdBy) {
    TicketLabel lb = new TicketMilestone(label);
    Repository db = null;
    try {
      db = repositoryManager.getRepository(repository.name);
      StoredConfig config = db.getConfig();
      config.setString(LABEL, label, COLOR, lb.color);
      config.save();
    } catch (IOException e) {
      log.error("failed to create label " + label + " in " + repository, e);
    } finally {
      if (db != null) {
        db.close();
View Full Code Here


   */
  public synchronized boolean updateLabel(RepositoryModel repository, TicketLabel label, String createdBy) {
    Repository db = null;
    try {
      db = repositoryManager.getRepository(repository.name);
      StoredConfig config = db.getConfig();
      config.setString(LABEL, label.name, COLOR, label.color);
      config.save();

      return true;
    } catch (IOException e) {
      log.error("failed to update label " + label + " in " + repository, e);
    } finally {
View Full Code Here

    }
    Repository db = null;
    try {
      db = repositoryManager.getRepository(repository.name);
      TicketLabel label = getLabel(repository, oldName);
      StoredConfig config = db.getConfig();
      config.unsetSection(LABEL, oldName);
      config.setString(LABEL, newName, COLOR, label.color);
      config.save();

      for (QueryResult qr : label.tickets) {
        Change change = new Change(createdBy);
        change.unlabel(oldName);
        change.label(newName);
View Full Code Here

      throw new IllegalArgumentException("label can not be empty!");
    }
    Repository db = null;
    try {
      db = repositoryManager.getRepository(repository.name);
      StoredConfig config = db.getConfig();
      config.unsetSection(LABEL, label);
      config.save();

      return true;
    } catch (IOException e) {
      log.error("failed to delete label " + label + " in " + repository, e);
    } finally {
View Full Code Here

      return milestonesCache.get(key);
    }
    List<TicketMilestone> list = new ArrayList<TicketMilestone>();
    Repository db = repositoryManager.getRepository(repository.name);
    try {
      StoredConfig config = db.getConfig();
      Set<String> names = config.getSubsections(MILESTONE);
      for (String name : names) {
        TicketMilestone milestone = new TicketMilestone(name);
        milestone.status = Status.fromObject(config.getString(MILESTONE, name, STATUS), milestone.status);
        milestone.color = config.getString(MILESTONE, name, COLOR);
        String due = config.getString(MILESTONE, name, DUE);
        if (!StringUtils.isEmpty(due)) {
          try {
            milestone.due = new SimpleDateFormat(DUE_DATE_PATTERN).parse(due);
          } catch (ParseException e) {
            log.error("failed to parse {} milestone {} due date \"{}\"",
View Full Code Here

  public synchronized TicketMilestone createMilestone(RepositoryModel repository, String milestone, String createdBy) {
    TicketMilestone ms = new TicketMilestone(milestone);
    Repository db = null;
    try {
      db = repositoryManager.getRepository(repository.name);
      StoredConfig config = db.getConfig();
      config.setString(MILESTONE, milestone, STATUS, ms.status.name());
      config.setString(MILESTONE, milestone, COLOR, ms.color);
      config.save();

      milestonesCache.remove(repository.name);
    } catch (IOException e) {
      log.error("failed to create milestone " + milestone + " in " + repository, e);
    } finally {
View Full Code Here

   */
  public synchronized boolean updateMilestone(RepositoryModel repository, TicketMilestone milestone, String createdBy) {
    Repository db = null;
    try {
      db = repositoryManager.getRepository(repository.name);
      StoredConfig config = db.getConfig();
      config.setString(MILESTONE, milestone.name, STATUS, milestone.status.name());
      config.setString(MILESTONE, milestone.name, COLOR, milestone.color);
      if (milestone.due != null) {
        config.setString(MILESTONE, milestone.name, DUE,
            new SimpleDateFormat(DUE_DATE_PATTERN).format(milestone.due));
      }
      config.save();

      milestonesCache.remove(repository.name);
      return true;
    } catch (IOException e) {
      log.error("failed to update milestone " + milestone + " in " + repository, e);
View Full Code Here

    }
    Repository db = null;
    try {
      db = repositoryManager.getRepository(repository.name);
      TicketMilestone milestone = getMilestone(repository, oldName);
      StoredConfig config = db.getConfig();
      config.unsetSection(MILESTONE, oldName);
      config.setString(MILESTONE, newName, STATUS, milestone.status.name());
      config.setString(MILESTONE, newName, COLOR, milestone.color);
      if (milestone.due != null) {
        config.setString(MILESTONE, milestone.name, DUE,
            new SimpleDateFormat(DUE_DATE_PATTERN).format(milestone.due));
      }
      config.save();

      milestonesCache.remove(repository.name);

      TicketNotifier notifier = createNotifier();
      for (QueryResult qr : milestone.tickets) {
View Full Code Here

      throw new IllegalArgumentException("milestone can not be empty!");
    }
    Repository db = null;
    try {
      db = repositoryManager.getRepository(repository.name);
      StoredConfig config = db.getConfig();
      config.unsetSection(MILESTONE, milestone);
      config.save();

      milestonesCache.remove(repository.name);

      return true;
    } catch (IOException e) {
View Full Code Here

   *
   * @param repository
   * @return true, if the refspecs were repaired
   */
  public static boolean repairFetchSpecs(Repository repository) {
    StoredConfig rc = repository.getConfig();

    // auto-repair broken fetch ref specs
    for (String name : rc.getSubsections("remote")) {
      int invalidSpecs = 0;
      int repairedSpecs = 0;
      List<String> specs = new ArrayList<String>();
      for (String spec : rc.getStringList("remote", name, "fetch")) {
        try {
          RefSpec rs = new RefSpec(spec);
          // valid spec
          specs.add(spec);
        } catch (IllegalArgumentException e) {
          // invalid spec
          invalidSpecs++;
          if (spec.contains("//")) {
            // auto-repair this known spec bug
            spec = spec.replace("//", "/");
            specs.add(spec);
            repairedSpecs++;
          }
        }
      }

      if (invalidSpecs == repairedSpecs && repairedSpecs > 0) {
        // the fetch specs were automatically repaired
        rc.setStringList("remote", name, "fetch", specs);
        try {
          rc.save();
          rc.load();
          LOGGER.debug("repaired {} invalid fetch refspecs for {}", repairedSpecs, repository.getDirectory());
          return true;
        } catch (Exception e) {
          LOGGER.error(null, e);
        }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.lib.StoredConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.