List of usage examples for org.eclipse.jgit.lib Constants CHARSET
Charset CHARSET
To view the source code for org.eclipse.jgit.lib Constants CHARSET.
Click Source Link
From source file:com.gitblit.tests.GitDaemonTest.java
License:Apache License
@Test public void testPushToNonBareRepository() throws Exception { GitBlitSuite.close(jgit2Folder);//from w ww .j av a 2s . c o m if (jgit2Folder.exists()) { FileUtils.delete(jgit2Folder, FileUtils.RECURSIVE | FileUtils.RETRY); } CloneCommand clone = Git.cloneRepository(); clone.setURI(MessageFormat.format("{0}/working/jgit", url)); clone.setDirectory(jgit2Folder); clone.setBare(false); clone.setCloneAllBranches(true); GitBlitSuite.close(clone.call()); assertTrue(true); Git git = Git.open(jgit2Folder); File file = new File(jgit2Folder, "NONBARE"); OutputStreamWriter os = new OutputStreamWriter(new FileOutputStream(file, true), Constants.CHARSET); BufferedWriter w = new BufferedWriter(os); w.write("// " + new Date().toString() + "\n"); w.close(); git.add().addFilepattern(file.getName()).call(); git.commit().setMessage("test commit followed by push to non-bare repository").call(); Iterable<PushResult> results = git.push().setPushAll().call(); GitBlitSuite.close(git); for (PushResult result : results) { for (RemoteRefUpdate update : result.getRemoteUpdates()) { assertEquals(Status.REJECTED_OTHER_REASON, update.getStatus()); } } }
From source file:com.gitblit.tests.TicketReferenceTest.java
License:Apache License
private static RevCommit makeCommit(String message) throws Exception { File file = new File(workingCopy, "testFile.txt"); OutputStreamWriter os = new OutputStreamWriter(new FileOutputStream(file, true), Constants.CHARSET); BufferedWriter w = new BufferedWriter(os); w.write("// " + new Date().toString() + "\n"); w.close();/* w ww . j av a 2 s . co m*/ git.add().addFilepattern(file.getName()).call(); RevCommit rev = git.commit().setMessage(message).call(); return rev; }
From source file:com.gitblit.tests.TicketReferenceTest.java
License:Apache License
private static String amendCommit(String message) throws Exception { File file = new File(workingCopy, "testFile.txt"); OutputStreamWriter os = new OutputStreamWriter(new FileOutputStream(file, true), Constants.CHARSET); BufferedWriter w = new BufferedWriter(os); w.write("// " + new Date().toString() + "\n"); w.close();//from w w w . j a v a 2 s .co m git.add().addFilepattern(file.getName()).call(); RevCommit rev = git.commit().setAmend(true).setMessage(message).call(); return rev.getId().name(); }
From source file:com.google.gerrit.server.patch.PatchListEntry.java
License:Apache License
public List<String> getHeaderLines() { final IntList m = RawParseUtils.lineMap(header, 0, header.length); final List<String> headerLines = new ArrayList<>(m.size() - 1); for (int i = 1; i < m.size() - 1; i++) { final int b = m.get(i); int e = m.get(i + 1); if (header[e - 1] == '\n') { e--;// w w w.jav a 2s .c o m } headerLines.add(RawParseUtils.decode(Constants.CHARSET, header, b, e)); } return headerLines; }
From source file:com.madgag.agit.filepath.FilePath.java
License:Open Source License
public synchronized String getPath() { if (path == null) { path = RawParseUtils.decode(Constants.CHARSET, rawPath); rawPath = null; // release memory }//from w w w.j a v a 2 s . c o m return path; }
From source file:com.surevine.gateway.scm.git.jgit.BundleWriter.java
License:Eclipse Distribution License
/** * Generate and write the bundle to the output stream. * <p>// w ww . j a v a 2 s . com * This method can only be called once per BundleWriter instance. * * @param monitor * progress monitor to report bundle writing status to. * @param os * the stream the bundle is written to. The stream should be * buffered by the caller. The caller is responsible for closing * the stream. * @throws IOException * an error occurred reading a local object's data to include in * the bundle, or writing compressed object data to the output * stream. */ public void writeBundle(ProgressMonitor monitor, OutputStream os) throws IOException { PackConfig pc = packConfig; if (pc == null) pc = new PackConfig(db); PackWriter packWriter = new PackWriter(pc, db.newObjectReader()); try { final HashSet<ObjectId> inc = new HashSet<ObjectId>(); final HashSet<ObjectId> exc = new HashSet<ObjectId>(); inc.addAll(include.values()); for (final RevCommit r : assume) exc.add(r.getId()); packWriter.setIndexDisabled(true); packWriter.setDeltaBaseAsOffset(true); packWriter.setThin(exc.size() > 0); packWriter.setReuseValidatingObjects(false); if (exc.size() == 0) packWriter.setTagTargets(tagTargets); packWriter.preparePack(monitor, inc, exc); final Writer w = new OutputStreamWriter(os, Constants.CHARSET); w.write(TransportBundle.V2_BUNDLE_SIGNATURE); w.write('\n'); final char[] tmp = new char[Constants.OBJECT_ID_STRING_LENGTH]; for (final RevCommit a : assume) { w.write('-'); a.copyTo(tmp, w); if (a.getRawBuffer() != null) { w.write(' '); w.write(a.getShortMessage()); } w.write('\n'); } for (final Map.Entry<String, ObjectId> e : include.entrySet()) { e.getValue().copyTo(tmp, w); w.write(' '); w.write(e.getKey()); w.write('\n'); } w.write('\n'); w.flush(); packWriter.writePack(monitor, monitor, os); } finally { packWriter.release(); } }
From source file:it.com.atlassian.labs.speakeasy.util.jgit.FixedTransportHttp.java
License:Eclipse Distribution License
private BufferedReader toBufferedReader(InputStream in) { return new BufferedReader(new InputStreamReader(in, Constants.CHARSET)); }
From source file:it.com.atlassian.labs.speakeasy.util.jgit.WalkRemoteObjectDatabase.java
License:Eclipse Distribution License
/** * Open a buffered reader around a file. * <p>//from w ww. j av a 2 s. co m * This is shorthand for calling {@link #open(String)} and then wrapping it * in a reader suitable for line oriented files like the alternates list. * * @return a stream to read from the file. Never null. * @param path * location of the file to read, relative to this objects * directory (e.g. <code>info/packs</code>). * @throws FileNotFoundException * the requested file does not exist at the given location. * @throws IOException * The connection is unable to read the remote's file, and the * failure occurred prior to being able to determine if the file * exists, or after it was determined to exist but before the * stream could be created. */ BufferedReader openReader(final String path) throws IOException { final InputStream is = open(path).in; return new BufferedReader(new InputStreamReader(is, Constants.CHARSET)); }
From source file:org.eclipse.egit.core.op.ConfigureGerritAfterCloneTask.java
License:Open Source License
private String runSshCommand(URIish sshUri, CredentialsProvider provider, FS fs, String command) throws IOException { RemoteSession session = null;//from w w w. j a v a2 s. c om Process process = null; StreamCopyThread errorThread = null; try (MessageWriter stderr = new MessageWriter()) { session = SshSessionFactory.getInstance().getSession(sshUri, provider, fs, 1000 * timeout); process = session.exec(command, 0); errorThread = new StreamCopyThread(process.getErrorStream(), stderr.getRawStream()); errorThread.start(); try (BufferedReader reader = new BufferedReader( new InputStreamReader(process.getInputStream(), Constants.CHARSET))) { return reader.readLine(); } } finally { if (errorThread != null) { try { errorThread.halt(); } catch (InterruptedException e) { // Stop waiting and return anyway. } finally { errorThread = null; } } if (process != null) { process.destroy(); } if (session != null) { SshSessionFactory.getInstance().releaseSession(session); } } }
From source file:org.eclipse.ptp.internal.rdt.sync.git.core.GitSyncFileFilter.java
License:Open Source License
@Override public void saveFilter() throws IOException { Repository repo = jgitRepo.getRepository(); File exclude = repo.getFS().resolve(repo.getDirectory(), Constants.INFO_EXCLUDE); exclude.getParentFile().mkdirs();//from w ww . ja va 2 s.c om FileOutputStream file = new FileOutputStream(exclude); BufferedWriter out = new BufferedWriter(new OutputStreamWriter(file, Constants.CHARSET)); try { for (AbstractIgnoreRule rule : rules) { out.write(rule.toString()); out.newLine(); } } finally { out.close(); } final RmCommand rmCommand = new RmCommand(repo); rmCommand.setCached(true); for (String fileName : getIgnoredFiles(null)) { rmCommand.addFilepattern(fileName); } try { rmCommand.call(); } catch (NoFilepatternException e) { new IOException(e); // TODO: a bit ugly to wrap it into IOExcpetion } catch (GitAPIException e) { new IOException(e); } }