List of usage examples for org.eclipse.jgit.lib Constants MASTER
String MASTER
To view the source code for org.eclipse.jgit.lib Constants MASTER.
Click Source Link
From source file:org.jenkinsci.git.LsRemoteOperationTest.java
License:Open Source License
/** * List remote on empty repository// w ww . j av a2 s . c o m * * @throws Exception */ @Test public void listEmptyRemote() throws Exception { Repository gitRepo = git.repo(); BuildRepository repo = new BuildRepository(gitRepo.getDirectory().toURI().toString(), Constants.R_HEADS + Constants.MASTER, null); LsRemoteOperation op = new LsRemoteOperation(repo, gitRepo); assertNull(op.call()); }
From source file:org.jenkinsci.git.LsRemoteOperationTest.java
License:Open Source License
/** * List remote on empty repository/*from w w w .j ava 2 s . com*/ * * @throws Exception */ @Test public void listRemote() throws Exception { Repository gitRepo = git.repo(); BuildRepository repo = new BuildRepository(gitRepo.getDirectory().toURI().toString(), Constants.R_HEADS + Constants.MASTER, null); LsRemoteOperation op = new LsRemoteOperation(repo, gitRepo); RevCommit commit1 = git.add("file.txt", "a"); assertEquals(commit1, op.call()); RevCommit commit2 = git.add("file.txt", "b"); assertEquals(commit2, op.call()); }
From source file:org.sonatype.m2e.egit.internal.EgitScmHandler.java
License:Open Source License
protected String getRefName(MavenProjectScmInfo info) { String branch = info.getBranch(); if (branch == null || branch.trim().length() == 0) { branch = Constants.MASTER; }/*from w w w .j av a2s . c om*/ if (!branch.startsWith(Constants.R_REFS)) { branch = Constants.R_HEADS + branch; } return branch; }
From source file:org.webcat.core.FilePickerDialog.java
License:Open Source License
private GitRef refForModelObject(Object object) { GitRef ref;/*from w w w.j av a2s.co m*/ if (object instanceof EOBase) { GitRepository repo = GitRepository.repositoryForObject((EOBase) object); ref = repo.refWithName(Constants.R_HEADS + Constants.MASTER); } else { ref = (GitRef) object; } return ref; }
From source file:org.webcat.core.git.GitRef.java
License:Open Source License
public boolean isMaster() { return name().equals(Constants.R_HEADS + Constants.MASTER); }
From source file:org.webcat.core.git.GitUtilities.java
License:Open Source License
@SuppressWarnings("deprecation") public static RevCommit pushWorkingCopyImmediately(Repository workingCopy, String authorName, String emailAddress, String commitMessage) { try {/*from www . j av a 2 s .c om*/ boolean amend = false; GitRepository gitRepo = new GitRepository(workingCopy); GitRef ref = gitRepo.refWithName(Constants.R_HEADS + Constants.MASTER); NSArray<GitCommit> commits = ref.commits(); if (commits != null && !commits.isEmpty()) { GitCommit commit = commits.objectAtIndex(0); if (commitMessage.equals(commit.shortMessage()) && commit.commitTime().timeIntervalSinceNow() > -3 * 60 * 60) { amend = true; } } Git git = new Git(workingCopy); git.add().addFilepattern(".").setUpdate(false).call(); RevCommit commit = git.commit().setAuthor(authorName, emailAddress) .setCommitter(authorName, emailAddress).setMessage(commitMessage).setAmend(amend).call(); RefSpec allHeadsSpec = new RefSpec().setForceUpdate(true).setSourceDestination( Constants.R_HEADS + Constants.MASTER, Constants.R_HEADS + Constants.MASTER); git.push().setRefSpecs(allHeadsSpec).call(); return commit; } catch (Exception e) { log.error("Error updating repository: ", e); } return null; }
From source file:org.webcat.core.git.http.GitWebContext.java
License:Open Source License
public GitWebContext(EOBase originator, GitRepository repository, String repositoryName, GitWebMode mode) { this.originator = originator; this.repository = repository; this.repositoryName = repositoryName; this.mode = mode; setHeadName(Constants.MASTER); }
From source file:org.webcat.core.git.http.GitWebContext.java
License:Open Source License
public static GitWebContext parse(EOBase originator, GitRepository repository, String repositoryName, String path) {//from w ww.ja v a 2 s. c o m GitWebContext newContext = null; if (path == null || path.length() == 0) { return new GitWebContext(originator, repository, repositoryName, GitWebMode.TREE, Constants.MASTER); } String typeString = null; String remainder = null; int firstSlash = path.indexOf('/'); if (firstSlash == -1) { typeString = path; } else { typeString = path.substring(0, firstSlash); remainder = path.substring(firstSlash + 1); } GitWebMode type = GitWebMode.valueOf(typeString.toUpperCase()); if (type != null) { switch (type) { case TREE: case COMMITS: case BLOB: case RAW: newContext = new GitWebContext(originator, repository, repositoryName, type, remainder); break; case BRANCHES: newContext = new GitWebContext(originator, repository, repositoryName, type); break; case COMMIT: newContext = new GitWebContext(originator, repository, repositoryName, type); newContext.headObjectId = ObjectId.fromString(remainder); break; case COMPARE: // TODO implement break; } } return newContext; }
From source file:org.webcat.core.RepositoryEntryRef.java
License:Open Source License
public static RepositoryEntryRef fromOldStylePath(String path) { Pattern pattern = Pattern.compile("^([^/]+)/([^/]+)(?:/(.*))?$"); Matcher matcher = pattern.matcher(path); if (matcher.matches()) { String authDomain = matcher.group(1); String username = matcher.group(2); String repoPath = matcher.group(3); // Make sure a slash is added to the end of old-style paths that // point to directories. File oldPath = new File(User.userDataRoot(), path); if (oldPath.isDirectory()) { repoPath += "/"; }/*from ww w. ja v a2 s . c o m*/ return new RepositoryEntryRef("User/" + authDomain + "." + username, repoPath, Constants.R_HEADS + Constants.MASTER); } else { return null; } }