本文整理匯總了Java中org.eclipse.jgit.api.CloneCommand.setBare方法的典型用法代碼示例。如果您正苦於以下問題:Java CloneCommand.setBare方法的具體用法?Java CloneCommand.setBare怎麽用?Java CloneCommand.setBare使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jgit.api.CloneCommand
的用法示例。
在下文中一共展示了CloneCommand.setBare方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doImport
import org.eclipse.jgit.api.CloneCommand; //導入方法依賴的package包/類
@Override
public void doImport(ProgressMonitor progress)
throws GitCloneFailedException, GitDestinationAlreadyExistsException,
GitDestinationNotWritableException {
CloneCommand clone = new CloneCommand();
clone.setCredentialsProvider(getRepository().getCredentialsProvider());
String sourceUri = getSourceUri();
clone.setURI(sourceUri);
clone.setBare(true);
clone.setDirectory(destinationDirectory);
if (progress != null) {
clone.setProgressMonitor(progress);
}
try {
LOG.info(sourceUri + "| Clone into " + destinationDirectory);
clone.call();
} catch (Throwable e) {
throw new GitCloneFailedException(sourceUri, e);
}
}
示例2: testAnonymousClone
import org.eclipse.jgit.api.CloneCommand; //導入方法依賴的package包/類
@Test
public void testAnonymousClone() throws Exception {
GitBlitSuite.close(ticgitFolder);
if (ticgitFolder.exists()) {
FileUtils.delete(ticgitFolder, FileUtils.RECURSIVE | FileUtils.RETRY);
}
// set push restriction
RepositoryModel model = GitBlit.self().getRepositoryModel("ticgit.git");
model.accessRestriction = AccessRestrictionType.PUSH;
model.authorizationControl = AuthorizationControl.NAMED;
GitBlit.self().updateRepositoryModel(model.name, model, false);
CloneCommand clone = Git.cloneRepository();
clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
clone.setDirectory(ticgitFolder);
clone.setBare(false);
clone.setCloneAllBranches(true);
GitBlitSuite.close(clone.call());
assertTrue(true);
// restore anonymous repository access
model.accessRestriction = AccessRestrictionType.NONE;
model.authorizationControl = AuthorizationControl.NAMED;
GitBlit.self().updateRepositoryModel(model.name, model, false);
}
示例3: testClone
import org.eclipse.jgit.api.CloneCommand; //導入方法依賴的package包/類
@Test
public void testClone() throws Exception {
GitBlitSuite.close(ticgitFolder);
if (ticgitFolder.exists()) {
FileUtils.delete(ticgitFolder, FileUtils.RECURSIVE | FileUtils.RETRY);
}
CloneCommand clone = Git.cloneRepository();
clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
clone.setDirectory(ticgitFolder);
clone.setBare(false);
clone.setCloneAllBranches(true);
clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password));
GitBlitSuite.close(clone.call());
assertTrue(true);
}
示例4: testCloneRestrictedRepo
import org.eclipse.jgit.api.CloneCommand; //導入方法依賴的package包/類
@Test
public void testCloneRestrictedRepo() throws Exception {
GitBlitSuite.close(ticgit2Folder);
if (ticgit2Folder.exists()) {
FileUtils.delete(ticgit2Folder, FileUtils.RECURSIVE);
}
// restrict repository access
RepositoryModel model = GitBlit.self().getRepositoryModel("ticgit.git");
model.accessRestriction = AccessRestrictionType.CLONE;
model.authorizationControl = AuthorizationControl.NAMED;
GitBlit.self().updateRepositoryModel(model.name, model, false);
// delete any existing working folder
boolean cloned = false;
try {
CloneCommand clone = Git.cloneRepository();
clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
clone.setDirectory(ticgit2Folder);
clone.setBare(false);
clone.setCloneAllBranches(true);
GitBlitSuite.close(clone.call());
cloned = true;
} catch (Exception e) {
// swallow the exception which we expect
}
assertFalse("Anonymous was able to clone the repository?!", cloned);
FileUtils.delete(ticgit2Folder, FileUtils.RECURSIVE);
// restore anonymous repository access
model.accessRestriction = AccessRestrictionType.NONE;
model.authorizationControl = AuthorizationControl.NAMED;
GitBlit.self().updateRepositoryModel(model.name, model, false);
}
示例5: testAnonymousPush
import org.eclipse.jgit.api.CloneCommand; //導入方法依賴的package包/類
@Test
public void testAnonymousPush() throws Exception {
GitBlitSuite.close(ticgitFolder);
if (ticgitFolder.exists()) {
FileUtils.delete(ticgitFolder, FileUtils.RECURSIVE | FileUtils.RETRY);
}
// restore anonymous repository access
RepositoryModel model = GitBlit.self().getRepositoryModel("ticgit.git");
model.accessRestriction = AccessRestrictionType.NONE;
model.authorizationControl = AuthorizationControl.NAMED;
GitBlit.self().updateRepositoryModel(model.name, model, false);
CloneCommand clone = Git.cloneRepository();
clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
clone.setDirectory(ticgitFolder);
clone.setBare(false);
clone.setCloneAllBranches(true);
GitBlitSuite.close(clone.call());
assertTrue(true);
Git git = Git.open(ticgitFolder);
File file = new File(ticgitFolder, "TODO");
OutputStreamWriter os = new OutputStreamWriter(new FileOutputStream(file, true), Constants.CHARSET);
BufferedWriter w = new BufferedWriter(os);
w.write("// hellol中文 " + new Date().toString() + "\n");
w.close();
git.add().addFilepattern(file.getName()).call();
git.commit().setMessage("test commit").call();
Iterable<PushResult> results = git.push().setPushAll().call();
GitBlitSuite.close(git);
for (PushResult result : results) {
for (RemoteRefUpdate update : result.getRemoteUpdates()) {
assertEquals(Status.OK, update.getStatus());
}
}
}
示例6: testPushRestrictedRepo
import org.eclipse.jgit.api.CloneCommand; //導入方法依賴的package包/類
@Test
public void testPushRestrictedRepo() throws Exception {
GitBlitSuite.close(ticgitFolder);
if (ticgitFolder.exists()) {
FileUtils.delete(ticgitFolder, FileUtils.RECURSIVE | FileUtils.RETRY);
}
// restore anonymous repository access
RepositoryModel model = GitBlit.self().getRepositoryModel("ticgit.git");
model.accessRestriction = AccessRestrictionType.PUSH;
model.authorizationControl = AuthorizationControl.NAMED;
GitBlit.self().updateRepositoryModel(model.name, model, false);
CloneCommand clone = Git.cloneRepository();
clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
clone.setDirectory(ticgitFolder);
clone.setBare(false);
clone.setCloneAllBranches(true);
GitBlitSuite.close(clone.call());
assertTrue(true);
Git git = Git.open(ticgitFolder);
File file = new File(ticgitFolder, "TODO");
OutputStreamWriter os = new OutputStreamWriter(new FileOutputStream(file, true), Constants.CHARSET);
BufferedWriter w = new BufferedWriter(os);
w.write("// hellol中文 " + new Date().toString() + "\n");
w.close();
git.add().addFilepattern(file.getName()).call();
git.commit().setMessage("test commit").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());
}
}
}
示例7: testPushToNonBareRepository
import org.eclipse.jgit.api.CloneCommand; //導入方法依賴的package包/類
@Test
public void testPushToNonBareRepository() throws Exception {
GitBlitSuite.close(jgit2Folder);
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());
}
}
}
示例8: testPushToNonBareRepository
import org.eclipse.jgit.api.CloneCommand; //導入方法依賴的package包/類
@Test
public void testPushToNonBareRepository() throws Exception {
CloneCommand clone = Git.cloneRepository();
clone.setURI(MessageFormat.format("{0}/working/jgit", url));
clone.setDirectory(jgit2Folder);
clone.setBare(false);
clone.setCloneAllBranches(true);
clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password));
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().setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password)).call();
GitBlitSuite.close(git);
for (PushResult result : results) {
for (RemoteRefUpdate update : result.getRemoteUpdates()) {
assertEquals(Status.REJECTED_OTHER_REASON, update.getStatus());
}
}
}
示例9: testBogusLoginClone
import org.eclipse.jgit.api.CloneCommand; //導入方法依賴的package包/類
@Test
public void testBogusLoginClone() throws Exception {
// restrict repository access
RepositoryModel model = GitBlit.self().getRepositoryModel("ticgit.git");
model.accessRestriction = AccessRestrictionType.CLONE;
GitBlit.self().updateRepositoryModel(model.name, model, false);
// delete any existing working folder
boolean cloned = false;
try {
CloneCommand clone = Git.cloneRepository();
clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
clone.setDirectory(ticgit2Folder);
clone.setBare(false);
clone.setCloneAllBranches(true);
clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider("bogus", "bogus"));
GitBlitSuite.close(clone.call());
cloned = true;
} catch (Exception e) {
// swallow the exception which we expect
}
// restore anonymous repository access
model.accessRestriction = AccessRestrictionType.NONE;
GitBlit.self().updateRepositoryModel(model.name, model, false);
assertFalse("Bogus login cloned a repository?!", cloned);
}
示例10: testAnonymousPush
import org.eclipse.jgit.api.CloneCommand; //導入方法依賴的package包/類
@Test
public void testAnonymousPush() throws Exception {
GitBlitSuite.close(ticgitFolder);
if (ticgitFolder.exists()) {
FileUtils.delete(ticgitFolder, FileUtils.RECURSIVE | FileUtils.RETRY);
}
RepositoryModel model = GitBlit.self().getRepositoryModel("ticgit.git");
model.accessRestriction = AccessRestrictionType.NONE;
GitBlit.self().updateRepositoryModel(model.name, model, false);
CloneCommand clone = Git.cloneRepository();
clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
clone.setDirectory(ticgitFolder);
clone.setBare(false);
clone.setCloneAllBranches(true);
clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password));
GitBlitSuite.close(clone.call());
assertTrue(true);
Git git = Git.open(ticgitFolder);
File file = new File(ticgitFolder, "TODO");
OutputStreamWriter os = new OutputStreamWriter(new FileOutputStream(file, true), Constants.CHARSET);
BufferedWriter w = new BufferedWriter(os);
w.write("// hellol中文 " + new Date().toString() + "\n");
w.close();
git.add().addFilepattern(file.getName()).call();
git.commit().setMessage("test commit").call();
Iterable<PushResult> results = git.push().setPushAll().call();
GitBlitSuite.close(git);
for (PushResult result : results) {
for (RemoteRefUpdate update : result.getRemoteUpdates()) {
assertEquals(Status.OK, update.getStatus());
}
}
}
示例11: testSubfolderPush
import org.eclipse.jgit.api.CloneCommand; //導入方法依賴的package包/類
@Test
public void testSubfolderPush() throws Exception {
GitBlitSuite.close(jgitFolder);
if (jgitFolder.exists()) {
FileUtils.delete(jgitFolder, FileUtils.RECURSIVE | FileUtils.RETRY);
}
CloneCommand clone = Git.cloneRepository();
clone.setURI(MessageFormat.format("{0}/test/jgit.git", url));
clone.setDirectory(jgitFolder);
clone.setBare(false);
clone.setCloneAllBranches(true);
clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password));
GitBlitSuite.close(clone.call());
assertTrue(true);
Git git = Git.open(jgitFolder);
File file = new File(jgitFolder, "TODO");
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").call();
Iterable<PushResult> results = git.push().setPushAll().setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password)).call();
GitBlitSuite.close(git);
for (PushResult result : results) {
for (RemoteRefUpdate update : result.getRemoteUpdates()) {
assertEquals(Status.OK, update.getStatus());
}
}
}
示例12: cloneRepo
import org.eclipse.jgit.api.CloneCommand; //導入方法依賴的package包/類
public void cloneRepo(String username, String reponame) throws InvalidRemoteException, TransportException, GitAPIException, IOException, ClassNotFoundException{
CloneCommand clonecommand = Git.cloneRepository();
RepoSettings rs = new RepoSettings(username,reponame,true);
File f = new File(rs.RepositoryPath);
clonecommand.setDirectory(f);
clonecommand.setBare(true);
String URI = "https://github.com/" + username + "/" + reponame + ".git";
clonecommand.setURI(URI);
File progress = new File(rs.Progress);
FileWriter pro = new FileWriter(progress);
pro.append("Cloning\n");
pro.flush();
pro.close();
//long startTime = System.nanoTime();
//Cloning the Bare Repo
git = clonecommand.call();
//long endTime = System.nanoTime();
//System.out.println("Took "+(endTime - startTime) + " ns");
Iterable<RevCommit> logsreverse = git.log().all().call(); //Latest top oldest last
List<RevCommit> logs = new ArrayList<RevCommit>();
for(RevCommit rev: logsreverse){
logs.add(rev);
}
Collections.reverse(logs); //Latest last, oldest top
if(logs.size() == 0) {
return;
}
pro = new FileWriter(progress);
pro.append("Building " + logs.size() + "\n");
pro.flush();
pro.close();
Buildmodel bm = new Buildmodel();
int numofcommits = bm.build(git,logs, rs); //How many commits written, i.e not merge commits in this
if(numofcommits > 200) {
numofcommits = 200;
}
pro = new FileWriter(progress);
pro.append("Detecting" + "\n");
pro.flush();
pro.close();
Detect detect = new Detect();
detect.detect(rs, numofcommits);
/*Htmldata htmd = new Htmldata();
htmd.initiate(username,reponame);
htmd.createhtml(new File(rs.Resultpath+"//result.tsv"));*/
pro = new FileWriter(progress);
pro.append("Completed" + "\n");
pro.flush();
pro.close();
}
示例13: testCommitterVerification
import org.eclipse.jgit.api.CloneCommand; //導入方法依賴的package包/類
private void testCommitterVerification(UserModel user, String displayName, String emailAddress, boolean expectedSuccess) throws Exception {
if (GitBlit.self().getUserModel(user.username) != null) {
GitBlit.self().deleteUser(user.username);
}
CredentialsProvider cp = new UsernamePasswordCredentialsProvider(user.username, user.password);
// fork from original to a temporary bare repo
File verification = new File(GitBlitSuite.REPOSITORIES, "refchecks/verify-committer.git");
if (verification.exists()) {
FileUtils.delete(verification, FileUtils.RECURSIVE);
}
CloneCommand clone = Git.cloneRepository();
clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
clone.setDirectory(verification);
clone.setBare(true);
clone.setCloneAllBranches(true);
clone.setCredentialsProvider(cp);
GitBlitSuite.close(clone.call());
// require push permissions and committer verification
RepositoryModel model = GitBlit.self().getRepositoryModel("refchecks/verify-committer.git");
model.authorizationControl = AuthorizationControl.NAMED;
model.accessRestriction = AccessRestrictionType.PUSH;
model.verifyCommitter = true;
// grant user push permission
user.setRepositoryPermission(model.name, AccessPermission.PUSH);
GitBlit.self().updateUserModel(user.username, user, true);
GitBlit.self().updateRepositoryModel(model.name, model, false);
// clone temp bare repo to working copy
File local = new File(GitBlitSuite.REPOSITORIES, "refchecks/verify-wc");
if (local.exists()) {
FileUtils.delete(local, FileUtils.RECURSIVE);
}
clone = Git.cloneRepository();
clone.setURI(MessageFormat.format("{0}/{1}", url, model.name));
clone.setDirectory(local);
clone.setBare(false);
clone.setCloneAllBranches(true);
clone.setCredentialsProvider(cp);
GitBlitSuite.close(clone.call());
Git git = Git.open(local);
// force an identity which may or may not match the account's identity
git.getRepository().getConfig().setString("user", null, "name", displayName);
git.getRepository().getConfig().setString("user", null, "email", emailAddress);
git.getRepository().getConfig().save();
// commit a file and push it
File file = new File(local, "PUSHCHK");
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("push test").call();
Iterable<PushResult> results = git.push().setCredentialsProvider(cp).setRemote("origin").call();
for (PushResult result : results) {
RemoteRefUpdate ref = result.getRemoteUpdate("refs/heads/master");
Status status = ref.getStatus();
if (expectedSuccess) {
assertTrue("Verification failed! User was NOT able to push commit! " + status.name(), Status.OK.equals(status));
} else {
assertTrue("Verification failed! User was able to push commit! " + status.name(), Status.REJECTED_OTHER_REASON.equals(status));
}
}
GitBlitSuite.close(git);
// close serving repository
GitBlitSuite.close(verification);
}