本文整理汇总了Java中org.eclipse.jgit.lib.Constants类的典型用法代码示例。如果您正苦于以下问题:Java Constants类的具体用法?Java Constants怎么用?Java Constants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Constants类属于org.eclipse.jgit.lib包,在下文中一共展示了Constants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findRemoteBranchName
import org.eclipse.jgit.lib.Constants; //导入依赖的package包/类
private String findRemoteBranchName () throws GitException {
Ref ref = null;
try {
ref = getRepository().getRef(branchToMerge);
} catch (IOException ex) {
throw new GitException(ex);
}
if (ref != null) {
for (String s : refSpecs) {
RefSpec spec = new RefSpec(s);
if (spec.matchDestination(ref)) {
spec = spec.expandFromDestination(ref);
String refName = spec.getSource();
if (refName.startsWith(Constants.R_HEADS)) {
return refName.substring(Constants.R_HEADS.length());
}
}
}
}
return branchToMerge;
}
示例2: testVisualDiff
import org.eclipse.jgit.lib.Constants; //导入依赖的package包/类
@Test
public void testVisualDiff() throws Exception {
XulMessageBox message = spy( new XulMessageBoxMock( XulDialogCallback.Status.ACCEPT ) );
when( document.createElement( MESSAGEBOX ) ).thenReturn( message );
UIFile file = new UIFile( "test.txt", ChangeType.MODIFY, true );
doReturn( Collections.singletonList( file ) ).when( controller ).getSelectedChangedFiles();
controller.visualdiff();
verify( message ).setTitle( BaseMessages.getString( PKG, "Dialog.Error" ) );
// .ktr
file = new UIFile( "test.ktr", ChangeType.MODIFY, true );
doReturn( Collections.singletonList( file ) ).when( controller ).getSelectedChangedFiles();
doReturn( new FileInputStream( new File( "src/test/resources/r1.ktr" ) ) ).when( uiGit ).open( "test.ktr", Constants.HEAD );
doReturn( new FileInputStream( new File( "src/test/resources/r2.ktr" ) ) ).when( uiGit ).open( "test.ktr", IVCS.WORKINGTREE );
controller.visualdiff();
verify( uiGit ).open( "test.ktr", Constants.HEAD );
verify( uiGit ).open( "test.ktr", IVCS.WORKINGTREE );
verify( controller ).loadMainPerspective();
// conflicted ktr
file = new UIFile( "test.kjb.ours", ChangeType.ADD, false );
File dir = File.createTempFile( "git_test_", "_controller" );
dir.delete();
dir.mkdir();
File ours = new File( dir.getPath(), "test.kjb.ours" );
File theirs = new File( dir.getPath(), "test.kjb.theirs" );
FileUtils.copyFile( new File( "src/test/resources/r1.kjb" ), ours );
FileUtils.copyFile( new File( "src/test/resources/r2.kjb" ), theirs );
doReturn( dir.getPath() ).when( uiGit ).getDirectory();
doReturn( Collections.singletonList( file ) ).when( controller ).getSelectedChangedFiles();
doReturn( new FileInputStream( ours ) ).when( uiGit ).open( "test.kjb.ours", IVCS.WORKINGTREE );
doReturn( new FileInputStream( theirs ) ).when( uiGit ).open( "test.kjb.theirs", IVCS.WORKINGTREE );
controller.visualdiff();
FileUtils.deleteDirectory( dir );
verify( uiGit ).open( "test.kjb.ours", IVCS.WORKINGTREE );
verify( uiGit ).open( "test.kjb.theirs", IVCS.WORKINGTREE );
verify( controller, times( 2 ) ).loadMainPerspective();
}
示例3: revertPath
import org.eclipse.jgit.lib.Constants; //导入依赖的package包/类
@Override
public void revertPath( String path ) {
try {
// Delete added files
Status status = git.status().addPath( path ).call();
if ( status.getUntracked().size() != 0 || status.getAdded().size() != 0 ) {
resetPath( path );
org.apache.commons.io.FileUtils.deleteQuietly( new File( directory, path ) );
}
/*
* This is a work-around to discard changes of conflicting files
* Git CLI `git checkout -- conflicted.txt` discards the changes, but jgit does not
*/
git.add().addFilepattern( path ).call();
git.checkout().setStartPoint( Constants.HEAD ).addPath( path ).call();
org.apache.commons.io.FileUtils.deleteQuietly( new File( directory, path + ".ours" ) );
org.apache.commons.io.FileUtils.deleteQuietly( new File( directory, path + ".theirs" ) );
} catch ( Exception e ) {
showMessageBox( BaseMessages.getString( PKG, "Dialog.Error" ), e.getMessage() );
}
}
示例4: createResult
import org.eclipse.jgit.lib.Constants; //导入依赖的package包/类
private GitRebaseResult createResult (RebaseResult res) {
String currHead;
Repository repository = getRepository();
File workTree = repository.getWorkTree();
try {
currHead = repository.resolve(Constants.HEAD).name();
} catch (IOException ex) {
currHead = Constants.HEAD;
}
List<File> conflicts;
if (res.getStatus() == RebaseResult.Status.STOPPED) {
conflicts = getConflicts(res.getCurrentCommit());
} else {
conflicts = Collections.<File>emptyList();
}
return getClassFactory().createRebaseResult(res, conflicts, getFailures(res), currHead);
}
示例5: stripRefs
import org.eclipse.jgit.lib.Constants; //导入依赖的package包/类
private static String stripRefs (String refName) {
if (refName == null) {
} else if (refName.startsWith(Constants.R_HEADS)) {
refName = refName.substring(Constants.R_HEADS.length());
} else if (refName.startsWith(Constants.R_TAGS)) {
refName = refName.substring(Constants.R_TAGS.length());
} else if (refName.startsWith(Constants.R_REMOTES)) {
refName = refName.substring(Constants.R_REMOTES.length());
} else if (refName.startsWith(Constants.R_REFS)) {
refName = refName.substring(Constants.R_REFS.length());
} else {
throw new IllegalArgumentException("Unknown refName: " + refName);
}
return refName;
}
示例6: getType
import org.eclipse.jgit.lib.Constants; //导入依赖的package包/类
private GitObjectType getType (RevObject object) {
GitObjectType objType = GitObjectType.UNKNOWN;
if (object != null) {
switch (object.getType()) {
case Constants.OBJ_COMMIT:
objType = GitObjectType.COMMIT;
break;
case Constants.OBJ_BLOB:
objType = GitObjectType.BLOB;
break;
case Constants.OBJ_TAG:
objType = GitObjectType.TAG;
break;
case Constants.OBJ_TREE:
objType = GitObjectType.TREE;
break;
}
}
return objType;
}
示例7: exportDiff
import org.eclipse.jgit.lib.Constants; //导入依赖的package包/类
/**
* Exports uncommitted changes in files under given roots to the given output stream
* @param roots the diff will be exported only for modified files under these roots, can be empty to export all modifications in the whole working tree
* @param mode defines the compared trees
* @param out output stream the diff will be printed to
* @param monitor progress monitor
* @throws GitException an unexpected error occurs
*/
public void exportDiff (File[] roots, DiffMode mode, OutputStream out, ProgressMonitor monitor) throws GitException {
switch (mode) {
case HEAD_VS_INDEX:
exportDiff(roots, Constants.HEAD, INDEX, out, monitor);
break;
case HEAD_VS_WORKINGTREE:
exportDiff(roots, Constants.HEAD, WORKING_TREE, out, monitor);
break;
case INDEX_VS_WORKINGTREE:
exportDiff(roots, INDEX, WORKING_TREE, out, monitor);
break;
default:
throw new IllegalArgumentException("Unknown diff mode: " + mode);
}
}
示例8: testIgnoreFolderIgnoredEqualPath
import org.eclipse.jgit.lib.Constants; //导入依赖的package包/类
public void testIgnoreFolderIgnoredEqualPath () throws Exception {
File f = new File(new File(new File(workDir, "sf1"), "sf2"), "folder");
f.mkdirs();
File gitIgnore = new File(workDir, Constants.DOT_GIT_IGNORE);
write(gitIgnore, "#ignoreFile\n/sf1/sf2/folder/");
File[] ignores = getClient(workDir).ignore(new File[] { f }, NULL_PROGRESS_MONITOR);
assertTrue(gitIgnore.exists());
assertEquals("#ignoreFile\n/sf1/sf2/folder/", read(gitIgnore));
assertEquals(0, ignores.length);
write(gitIgnore, "#ignoreFile\n/sf1/sf2/folder");
ignores = getClient(workDir).ignore(new File[] { f }, NULL_PROGRESS_MONITOR);
assertTrue(gitIgnore.exists());
assertEquals("#ignoreFile\n/sf1/sf2/folder", read(gitIgnore));
assertEquals(0, ignores.length);
}
示例9: testIgnoreFolderIgnoredPartialEqualPath
import org.eclipse.jgit.lib.Constants; //导入依赖的package包/类
public void testIgnoreFolderIgnoredPartialEqualPath () throws Exception {
File f = new File(new File(new File(workDir, "sf1"), "sf2"), "folder");
f.mkdirs();
new File(f, "file").createNewFile();
File gitIgnore = new File(workDir, Constants.DOT_GIT_IGNORE);
write(gitIgnore, "#ignoreFile\nfolder");
File[] ignores = getClient(workDir).ignore(new File[] { f }, NULL_PROGRESS_MONITOR);
assertTrue(gitIgnore.exists());
assertEquals("#ignoreFile\nfolder", read(gitIgnore));
assertEquals(0, ignores.length);
write(gitIgnore, "#ignoreFile\nfolder/");
ignores = getClient(workDir).ignore(new File[] { f }, NULL_PROGRESS_MONITOR);
assertTrue(gitIgnore.exists());
assertEquals("#ignoreFile\nfolder/", read(gitIgnore));
assertEquals(0, ignores.length);
}
示例10: testIgnoreRemoveNegation
import org.eclipse.jgit.lib.Constants; //导入依赖的package包/类
public void testIgnoreRemoveNegation () throws Exception {
File f = new File(new File(new File(workDir, "sf1"), "sf2"), "file");
f.getParentFile().mkdirs();
f.createNewFile();
File gitIgnore = new File(workDir, Constants.DOT_GIT_IGNORE);
write(gitIgnore, "#ignoreFile\n/sf1/sf2/file\n!/sf1/sf2/file");
File[] ignores = getClient(workDir).ignore(new File[] { f }, NULL_PROGRESS_MONITOR);
assertTrue(gitIgnore.exists());
assertEquals("#ignoreFile\n/sf1/sf2/file", read(gitIgnore));
assertEquals(Arrays.asList(gitIgnore), Arrays.asList(ignores));
write(gitIgnore, "");
File ignore2 = new File(f.getParentFile().getParentFile(), Constants.DOT_GIT_IGNORE);
write(ignore2, "!sf2/file");
ignores = getClient(workDir).ignore(new File[] { f }, NULL_PROGRESS_MONITOR);
assertTrue(gitIgnore.exists());
assertEquals("/sf1/sf2/file", read(gitIgnore));
assertEquals("", read(ignore2));
assertEquals(Arrays.asList(ignore2, gitIgnore), Arrays.asList(ignores));
}
示例11: testIgnoreFolderNoNegationRemoval
import org.eclipse.jgit.lib.Constants; //导入依赖的package包/类
public void testIgnoreFolderNoNegationRemoval () throws Exception {
File f = new File(new File(new File(workDir, "sf1"), "sf2"), "folder");
f.mkdirs();
File gitIgnore = new File(workDir, Constants.DOT_GIT_IGNORE);
write(gitIgnore, "#ignoreFile\n/sf1/sf2/folder\n!folder");
File[] ignores = getClient(workDir).ignore(new File[] { f }, NULL_PROGRESS_MONITOR);
assertTrue(gitIgnore.exists());
assertEquals("#ignoreFile\n/sf1/sf2/folder\n!folder\n/sf1/sf2/folder/", read(gitIgnore));
assertEquals(Arrays.asList(gitIgnore), Arrays.asList(ignores));
write(gitIgnore, "#ignoreFile\n/sf1/sf2/folder\n!/sf1/sf2/folder");
ignores = getClient(workDir).ignore(new File[] { f }, NULL_PROGRESS_MONITOR);
assertTrue(gitIgnore.exists());
assertEquals("#ignoreFile\n/sf1/sf2/folder\n!/sf1/sf2/folder\n/sf1/sf2/folder/", read(gitIgnore));
assertEquals(Arrays.asList(gitIgnore), Arrays.asList(ignores));
}
示例12: testCatRemoved
import org.eclipse.jgit.lib.Constants; //导入依赖的package包/类
public void testCatRemoved () throws Exception {
File f = new File(workDir, "removed");
copyFile(getGoldenFile(), f);
assertFile(getGoldenFile(), f);
add(f);
commit(f);
GitClient client = getClient(workDir);
String revision = new Git(repository).log().call().iterator().next().getId().getName();
// remove and commit
client.remove(new File[] { f }, false, NULL_PROGRESS_MONITOR);
commit(f);
assertTrue(client.catFile(f, revision, new FileOutputStream(f), NULL_PROGRESS_MONITOR));
assertFile(f, getGoldenFile());
assertFalse(client.catFile(f, Constants.HEAD, new FileOutputStream(f), NULL_PROGRESS_MONITOR));
}
示例13: testIgnoreRemoveNegation_NestedIgnoreFile
import org.eclipse.jgit.lib.Constants; //导入依赖的package包/类
public void testIgnoreRemoveNegation_NestedIgnoreFile () throws Exception {
File f = new File(new File(new File(workDir, "sf1"), "sf2"), "file");
f.getParentFile().mkdirs();
f.createNewFile();
File gitIgnore = new File(f.getParentFile().getParentFile(), Constants.DOT_GIT_IGNORE);
write(gitIgnore, "#ignoreFile\n/sf2/file\n!/sf2/file");
File[] ignores = getClient(workDir).ignore(new File[] { f }, NULL_PROGRESS_MONITOR);
assertTrue(gitIgnore.exists());
assertEquals("#ignoreFile\n/sf2/file", read(gitIgnore));
assertFalse(new File(workDir, Constants.DOT_GIT_IGNORE).exists());
assertEquals(Arrays.asList(gitIgnore), Arrays.asList(ignores));
write(gitIgnore, "sf2/file\n!sf2/file");
ignores = getClient(workDir).ignore(new File[] { f }, NULL_PROGRESS_MONITOR);
assertTrue(gitIgnore.exists());
assertEquals("sf2/file", read(gitIgnore));
assertFalse(new File(workDir, Constants.DOT_GIT_IGNORE).exists());
assertEquals(Arrays.asList(gitIgnore), Arrays.asList(ignores));
write(gitIgnore, "#ignoreFile\nsf2/f*\n!/sf2/file");
ignores = getClient(workDir).ignore(new File[] { f }, NULL_PROGRESS_MONITOR);
assertTrue(gitIgnore.exists());
assertEquals("#ignoreFile\nsf2/f*", read(gitIgnore));
assertFalse(new File(workDir, Constants.DOT_GIT_IGNORE).exists());
assertEquals(Arrays.asList(gitIgnore), Arrays.asList(ignores));
}
示例14: testIgnoreFolderRemoveNegation_NestedIgnoreFile
import org.eclipse.jgit.lib.Constants; //导入依赖的package包/类
public void testIgnoreFolderRemoveNegation_NestedIgnoreFile () throws Exception {
File f = new File(new File(new File(workDir, "sf1"), "sf2"), "folder");
f.mkdirs();
File gitIgnore = new File(f.getParentFile().getParentFile(), Constants.DOT_GIT_IGNORE);
write(gitIgnore, "#ignoreFile\n/sf2/folder/\n!/sf2/folder/");
File[] ignores = getClient(workDir).ignore(new File[] { f }, NULL_PROGRESS_MONITOR);
assertTrue(gitIgnore.exists());
assertEquals("#ignoreFile\n/sf2/folder/", read(gitIgnore));
assertFalse(new File(workDir, Constants.DOT_GIT_IGNORE).exists());
assertEquals(Arrays.asList(gitIgnore), Arrays.asList(ignores));
write(gitIgnore, "#ignoreFile\nsf2/f*\n!/sf2/folder/");
ignores = getClient(workDir).ignore(new File[] { f }, NULL_PROGRESS_MONITOR);
assertTrue(gitIgnore.exists());
assertEquals("#ignoreFile\nsf2/f*", read(gitIgnore));
assertFalse(new File(workDir, Constants.DOT_GIT_IGNORE).exists());
assertEquals(Arrays.asList(gitIgnore), Arrays.asList(ignores));
}
示例15: testIgnoreFileWithBracket
import org.eclipse.jgit.lib.Constants; //导入依赖的package包/类
public void testIgnoreFileWithBracket () throws Exception {
File f = new File(workDir, "fi[le");
f.createNewFile();
File gitIgnore = new File(workDir, Constants.DOT_GIT_IGNORE);
File[] ignores = getClient(workDir).ignore(new File[] { f }, NULL_PROGRESS_MONITOR);
assertEquals("/fi[[]le", read(gitIgnore));
assertEquals(Arrays.asList(gitIgnore), Arrays.asList(ignores));
write(gitIgnore, "/fi[[]le");
GitStatus st = getClient(workDir).getStatus(new File[] { f }, NULL_PROGRESS_MONITOR).get(f);
assertEquals(Status.STATUS_IGNORED, st.getStatusIndexWC());
ignores = getClient(workDir).ignore(new File[] { f }, NULL_PROGRESS_MONITOR);
assertEquals("/fi[[]le", read(gitIgnore));
assertEquals(0, ignores.length);
write(gitIgnore, "/fi\\[le");
// jgit seems to incorrectly handle escaped wildcards
st = getClient(workDir).getStatus(new File[] { f }, NULL_PROGRESS_MONITOR).get(f);
assertEquals(Status.STATUS_IGNORED, st.getStatusIndexWC());
ignores = getClient(workDir).ignore(new File[] { f }, NULL_PROGRESS_MONITOR);
assertEquals("/fi\\[le", read(gitIgnore));
assertEquals(0, ignores.length);
}