List of usage examples for org.eclipse.jgit.pgm Die Die
public Die(boolean aborted)
From source file:com.sap.poc.jgit.storage.jdbc.pgm.Main.java
License:Eclipse Distribution License
@Override protected Repository openGitDir(final String gitdir) throws IOException { if (gitdir != null && gitdir.startsWith(GIT_JDBC_PREFIX)) { try {// w w w .j a va2s . c o m return new JdbcRepositoryBuilder().setURI(gitdir).build(); } catch (URISyntaxException e) { throw new Die("Invalid URI " + gitdir); } } return super.openGitDir(gitdir); }
From source file:kr.re.ec.grigit.util.PgmMain.java
License:Eclipse Distribution License
/** * Evaluate the {@code --git-dir} option and open the repository. * * @param gitdir//from ww w . ja v a 2 s . c om * the {@code --git-dir} option given on the command line. May be * null if it was not supplied. * @return the repository to operate on. * @throws IOException * the repository cannot be opened. */ protected Repository openGitDir(String gitdir) throws IOException { RepositoryBuilder rb = new RepositoryBuilder() // .setGitDir(gitdir != null ? new File(gitdir) : null) // .readEnvironment() // .findGitDir(); if (rb.getGitDir() == null) throw new Die(CLIText.get().cantFindGitDirectory); return rb.build(); }
From source file:org.apache.sshd.git.pgm.EmbeddedCommandRunner.java
License:Apache License
/** * Execute a command./*from ww w.jav a 2 s . com*/ * * @param argv * the command and its arguments * @param in * the input stream, may be null in which case the system input stream will be used * @param out * the output stream, may be null in which case the system output stream will be used * @param err * the error stream, may be null in which case the system error stream will be used * @throws Exception * if an error occurs */ public void execute(final String[] argv, InputStream in, OutputStream out, OutputStream err) throws Exception { final CmdLineParser clp = new CmdLineParser(this); PrintWriter writer = new PrintWriter(err != null ? err : System.err); try { clp.parseArgument(argv); } catch (CmdLineException e) { if (argv.length > 0 && !help) { writer.println(MessageFormat.format(CLIText.get().fatalError, e.getMessage())); writer.flush(); throw new Die(true); } } if (argv.length == 0 || help) { final String ex = clp.printExample(ExampleMode.ALL, CLIText.get().resourceBundle()); writer.println("jgit" + ex + " command [ARG ...]"); //$NON-NLS-1$ if (help) { writer.println(); clp.printUsage(writer, CLIText.get().resourceBundle()); writer.println(); } else if (subcommand == null) { writer.println(); writer.println(CLIText.get().mostCommonlyUsedCommandsAre); final CommandRef[] common = CommandCatalog.common(); int width = 0; for (final CommandRef c : common) { width = Math.max(width, c.getName().length()); } width += 2; for (final CommandRef c : common) { writer.print(' '); writer.print(c.getName()); for (int i = c.getName().length(); i < width; i++) { writer.print(' '); } writer.print(CLIText.get().resourceBundle().getString(c.getUsage())); writer.println(); } writer.println(); } writer.flush(); throw new Die(true); } gitdir = new File(rootDir, gitdir).getPath(); final TextBuiltin cmd = subcommand; // cmd.ins = in; // cmd.outs = out; // cmd.errs = err; // if (cmd.requiresRepository()) // cmd.init(openGitDir(gitdir), null); // else // cmd.init(null, gitdir); // try { // cmd.execute(arguments.toArray(new String[arguments.size()])); // } finally { // if (cmd.outw != null) // cmd.outw.flush(); // if (cmd.errw != null) // cmd.errw.flush(); // } set(cmd, "ins", in); set(cmd, "outs", out); set(cmd, "errs", err); Boolean success = (Boolean) call(cmd, "requiresRepository"); if (success) { call(cmd, "init", new Class[] { Repository.class, String.class }, new Object[] { openGitDir(gitdir), gitdir }); } else { call(cmd, "init", new Class[] { Repository.class, String.class }, new Object[] { null, gitdir }); } try { cmd.execute(arguments.toArray(new String[arguments.size()])); } finally { if (get(cmd, "outw") != null) { ((ThrowingPrintWriter) get(cmd, "outw")).flush(); } if (get(cmd, "errw") != null) { ((ThrowingPrintWriter) get(cmd, "errw")).flush(); } } }
From source file:org.jboss.forge.git.Clone.java
License:Eclipse Distribution License
private void doCheckout(final Ref branch) throws IOException { if (branch == null) throw new Die(CLIText.get().cannotChekoutNoHeadsAdvertisedByRemote); if (!Constants.HEAD.equals(branch.getName())) { RefUpdate u = db.updateRef(Constants.HEAD); u.disableRefLog();//from www .ja v a 2s. co m u.link(branch.getName()); } final RevCommit commit = parseCommit(branch); final RefUpdate u = db.updateRef(Constants.HEAD); u.setNewObjectId(commit); u.forceUpdate(); DirCache dc = db.lockDirCache(); DirCacheCheckout co = new DirCacheCheckout(db, dc, commit.getTree()); co.checkout(); }