Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.StoredConfig


        throw new RuntimeException(e);
      }

      GitConfigSharedRepository sharedRepository = new GitConfigSharedRepository(shared);
      if (sharedRepository.isShared()) {
        StoredConfig config = repo.getConfig();
        config.setString("core", null, "sharedRepository", sharedRepository.getValue());
        config.setBoolean("receive", null, "denyNonFastforwards", true);
        config.save();

        if (! JnaUtils.isWindows()) {
          Iterator<File> iter = org.apache.commons.io.FileUtils.iterateFilesAndDirs(repo.getDirectory(),
              TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
          // Adjust permissions on file/directory
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

  private void setSizeAndPosition() {
    String sz = null;
    String pos = null;
    try {
      StoredConfig config = getConfig();
      sz = config.getString("ui", null, "size");
      pos = config.getString("ui", null, "position");
      defaultDuration = config.getInt("new""duration", 365);
    } catch (Throwable t) {
      t.printStackTrace();
    }

    // try to restore saved window size
View Full Code Here

  }

  private void saveSizeAndPosition() {
    try {
      // save window size and position
      StoredConfig config = getConfig();
      Dimension sz = GitblitAuthority.this.getSize();
      config.setString("ui", null, "size",
          MessageFormat.format("{0,number,0}x{1,number,0}", sz.width, sz.height));
      Point pos = GitblitAuthority.this.getLocationOnScreen();
      config.setString("ui", null, "position",
          MessageFormat.format("{0,number,0},{1,number,0}", pos.x, pos.y));
      config.save();
    } catch (Throwable t) {
      Utils.showException(GitblitAuthority.this, t);
    }
  }
View Full Code Here

      return labelsCache.get(key);
    }
    List<TicketLabel> list = new ArrayList<TicketLabel>();
    Repository db = repositoryManager.getRepository(repository.name);
    try {
      StoredConfig config = db.getConfig();
      Set<String> names = config.getSubsections(LABEL);
      for (String name : names) {
        TicketLabel label = new TicketLabel(name);
        label.color = config.getString(LABEL, name, COLOR);
        list.add(label);
      }
      labelsCache.put(key,  Collections.unmodifiableList(list));
    } catch (Exception e) {
      log.error("invalid tickets settings for " + repository, e);
View Full Code Here

  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

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.