Пример #1
0
  /**
   * Adds the all.
   *
   * @param g the g
   */
  public void addAll(Git g) {

    try {
      g.add().addFilepattern(".").call();

      System.out.println("Added all to repository at " + g.getRepository().getDirectory());

    } catch (NoFilepatternException e) {
      e.printStackTrace();
    } catch (GitAPIException e) {
      e.printStackTrace();
    }
  }
Пример #2
0
  // This will probs end up being static
  public static void addFile(Git g, String fileName) {
    File myFile = new File(g.getRepository().getDirectory().getParent(), fileName);

    try {
      myFile.createNewFile();
    } catch (IOException e) {
      e.printStackTrace();
      return;
    }

    try {
      g.add().addFilepattern(fileName).call();

      System.out.println(
          "Added file " + myFile + " to repository at " + g.getRepository().getDirectory());

    } catch (NoFilepatternException e) {
      e.printStackTrace();
    } catch (GitAPIException e) {
      e.printStackTrace();
    }
  }