本文整理汇总了Java中org.eclipse.jgit.diff.DiffEntry.ChangeType类的典型用法代码示例。如果您正苦于以下问题:Java ChangeType类的具体用法?Java ChangeType怎么用?Java ChangeType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChangeType类属于org.eclipse.jgit.diff.DiffEntry包,在下文中一共展示了ChangeType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStagedFiles
import org.eclipse.jgit.diff.DiffEntry.ChangeType; //导入依赖的package包/类
@Override
public List<UIFile> getStagedFiles() {
List<UIFile> files = new ArrayList<UIFile>();
Status status = null;
try {
status = git.status().call();
} catch ( Exception e ) {
e.printStackTrace();
return files;
}
status.getAdded().forEach( name -> {
files.add( new UIFile( name, ChangeType.ADD, true ) );
} );
status.getChanged().forEach( name -> {
files.add( new UIFile( name, ChangeType.MODIFY, true ) );
} );
status.getRemoved().forEach( name -> {
files.add( new UIFile( name, ChangeType.DELETE, true ) );
} );
return files;
}
示例2: convertChangeType
import org.eclipse.jgit.diff.DiffEntry.ChangeType; //导入依赖的package包/类
protected nl.tudelft.ewi.git.models.ChangeType convertChangeType(ChangeType changeType) {
switch (changeType) {
case ADD:
return nl.tudelft.ewi.git.models.ChangeType.ADD;
case COPY:
return nl.tudelft.ewi.git.models.ChangeType.COPY;
case DELETE:
return nl.tudelft.ewi.git.models.ChangeType.DELETE;
case MODIFY:
return nl.tudelft.ewi.git.models.ChangeType.MODIFY;
case RENAME:
return nl.tudelft.ewi.git.models.ChangeType.RENAME;
default:
throw new IllegalArgumentException("Cannot convert change type: " + changeType);
}
}
示例3: onInitialize
import org.eclipse.jgit.diff.DiffEntry.ChangeType; //导入依赖的package包/类
@Override
protected void onInitialize() {
super.onInitialize();
add(new Label("renamedTitle", change.getOldBlobIdent().path)
.setVisible(change.getType() == ChangeType.RENAME));
add(new Label("title", change.getPath()));
String modeChange;
if (change.getOldBlobIdent().mode != null && change.getNewBlobIdent().mode != null
&& !change.getOldBlobIdent().mode.equals(change.getNewBlobIdent().mode)) {
modeChange = Integer.toString(change.getOldBlobIdent().mode, 8)
+ " <i class='fa fa-long-arrow-right'></i> "
+ Integer.toString(change.getNewBlobIdent().mode, 8);
} else {
modeChange = null;
}
add(new Label("modeChange", modeChange).setEscapeModelStrings(false));
}
示例4: getUnstagedFiles
import org.eclipse.jgit.diff.DiffEntry.ChangeType; //导入依赖的package包/类
@Override
public List<UIFile> getUnstagedFiles() {
List<UIFile> files = new ArrayList<UIFile>();
Status status = null;
try {
status = git.status().call();
} catch ( Exception e ) {
e.printStackTrace();
return files;
}
status.getUntracked().forEach( name -> {
files.add( new UIFile( name, ChangeType.ADD, false ) );
} );
status.getModified().forEach( name -> {
files.add( new UIFile( name, ChangeType.MODIFY, false ) );
} );
status.getConflicting().forEach( name -> {
files.add( new UIFile( name, ChangeType.MODIFY, false ) );
} );
status.getMissing().forEach( name -> {
files.add( new UIFile( name, ChangeType.DELETE, false ) );
} );
return files;
}
示例5: testGetUnStagedFiles
import org.eclipse.jgit.diff.DiffEntry.ChangeType; //导入依赖的package包/类
@Test
public void testGetUnStagedFiles() throws Exception {
List<UIFile> files;
// Create a new file
File file = new File( rootClient.getPath(), "test.txt" );
FileUtils.write( file, "Hello World" );
File dir = new File( rootClient.getPath(), "folder" );
dir.mkdir();
// New file should be listed in the list of unstaged files
files = vcs.getUnstagedFiles();
assertTrue( files.stream().anyMatch( f -> f.getName().equals( "test.txt" ) && f.getChangeType() == ChangeType.ADD ) );
assertTrue( files.stream().anyMatch( f -> f.getName().equals( "folder" ) && f.getChangeType() == ChangeType.ADD ) );
// First commit
vcs.add( "test.txt" );
vcs.commit( "user", "message" );
// Test if delete files are listed in the list of staged files
file.delete();
files = vcs.getUnstagedFiles();
assertTrue( files.stream().anyMatch( f -> f.getName().equals( "test.txt" ) && f.getChangeType() == ChangeType.DELETE ) );
}
示例6: testOpenFile
import org.eclipse.jgit.diff.DiffEntry.ChangeType; //导入依赖的package包/类
@Test
public void testOpenFile() throws Exception {
UIFile 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", IVCS.WORKINGTREE );
controller.openFile();
verify( controller ).loadMainPerspective();
file = new UIFile( "test.kjb", ChangeType.MODIFY, true );
doReturn( false ).when( controller ).isOnlyWIP();
doReturn( new UIRepositoryObjectRevision( new PurObjectRevision( "XXX", "", null, "" ) ) ).when( controller ).getFirstSelectedRevision();
doReturn( Collections.singletonList( file ) ).when( controller ).getSelectedChangedFiles();
doReturn( new FileInputStream( new File( "src/test/resources/r1.ktr" ) ) ).when( uiGit ).open( "test.kjb", "XXX" );
controller.openFile();
verify( controller, times( 2 ) ).loadMainPerspective();
}
示例7: testVisualDiff
import org.eclipse.jgit.diff.DiffEntry.ChangeType; //导入依赖的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();
}
示例8: ofNewCommit
import org.eclipse.jgit.diff.DiffEntry.ChangeType; //导入依赖的package包/类
public static DiffInfo ofNewCommit(FileContent fileContent) {
DiffInfo diffInfo = new DiffInfo(null, null, fileContent.getPath(), ChangeType.ADD,
fileContent.isBinary(), /*null, fileContent.getText(),*/ null);
if (!fileContent.isBinary()) {
DiffBlock diffBlock = new DiffBlock(0, 0);
String[] lines = fileContent.getText().split("\n");
for (int i = 0; i < lines.length; i++) {
DiffLine diffLine = new DiffLine(2, lines[i]);
diffLine.setALine(0);
diffLine.setBLine(i);
diffBlock.getDiffLines().add(diffLine);
}
diffBlock.setEnd(false, 0, lines.length);
diffInfo.diffBlocks = Arrays.asList(diffBlock);
}
return diffInfo;
}
示例9: setChangeTypeTooltip
import org.eclipse.jgit.diff.DiffEntry.ChangeType; //导入依赖的package包/类
protected void setChangeTypeTooltip(Component container, ChangeType type) {
switch (type) {
case ADD:
WicketUtils.setHtmlTooltip(container, getString("gb.addition"));
break;
case COPY:
case RENAME:
WicketUtils.setHtmlTooltip(container, getString("gb.rename"));
break;
case DELETE:
WicketUtils.setHtmlTooltip(container, getString("gb.deletion"));
break;
case MODIFY:
WicketUtils.setHtmlTooltip(container, getString("gb.modification"));
break;
}
}
示例10: setChangeTypeCssClass
import org.eclipse.jgit.diff.DiffEntry.ChangeType; //导入依赖的package包/类
public static void setChangeTypeCssClass(Component container, ChangeType type) {
switch (type) {
case ADD:
setCssClass(container, "addition");
break;
case COPY:
case RENAME:
setCssClass(container, "rename");
break;
case DELETE:
setCssClass(container, "deletion");
break;
case MODIFY:
setCssClass(container, "modification");
break;
}
}
示例11: visitRev
import org.eclipse.jgit.diff.DiffEntry.ChangeType; //导入依赖的package包/类
private void visitRev(Rev rev, int number) {
Timer visitAllTimer = visitAllStat.timer();
visitor.onStartRev(rev, null, number);
for (ParentRelation parentRelation: rev.getParentRelations()) {
for (Diff diff : parentRelation.getDiffs()) {
if (diff.getType() == ChangeType.ADD) {
visitor.onAddedFile(diff);
} else if (diff.getType() == ChangeType.COPY) {
visitor.onCopiedFile(diff);
} else if (diff.getType() == ChangeType.DELETE) {
visitor.onDeletedFile(diff);
} else if (diff.getType() == ChangeType.MODIFY) {
visitor.onModifiedFile(diff);
} else if (diff.getType() == ChangeType.RENAME) {
visitor.onRenamedFile(diff);
}
}
}
visitor.onCompleteRev(rev, null);
visitAllTimer.track();
}
示例12: visitRev
import org.eclipse.jgit.diff.DiffEntry.ChangeType; //导入依赖的package包/类
private void visitRev(Rev rev, Rev traverseParentRev, int number) {
Preconditions.checkArgument(!traversedRevs.contains(rev));
Timer visitAllTimer = visitFullETStat.timer();
visitor.onStartRev(rev,traverseParentRev, number);
for (ParentRelation parentRelation: rev.getParentRelations()) {
for (Diff diff : parentRelation.getDiffs()) {
if (diff.getType() == ChangeType.ADD) {
visitor.onAddedFile(diff);
} else if (diff.getType() == ChangeType.COPY) {
visitor.onCopiedFile(diff);
} else if (diff.getType() == ChangeType.DELETE) {
visitor.onDeletedFile(diff);
} else if (diff.getType() == ChangeType.MODIFY) {
visitor.onModifiedFile(diff);
} else if (diff.getType() == ChangeType.RENAME) {
visitor.onRenamedFile(diff);
}
}
}
visitor.onCompleteRev(rev, traverseParentRev);
visitAllTimer.track();
}
示例13: onInitialize
import org.eclipse.jgit.diff.DiffEntry.ChangeType; //导入依赖的package包/类
@Override
protected void onInitialize() {
super.onInitialize();
if (change.getType() == ChangeType.ADD || change.getType() == ChangeType.COPY) {
showBlob(change.getNewBlob());
} else if (change.getType() == ChangeType.DELETE) {
showBlob(change.getOldBlob());
} else {
if (change.getOldText() != null && change.getNewText() != null) {
if (change.getOldText().getLines().size() + change.getNewText().getLines().size() > DiffUtils.MAX_DIFF_SIZE) {
add(newFragment("Unable to diff as the file is too large.", true));
} else if (change.getAdditions() + change.getDeletions() > WebConstants.MAX_SINGLE_FILE_DIFF_LINES) {
add(newFragment("Diff is too large to be displayed.", true));
} else if (change.getAdditions() + change.getDeletions() == 0
&& (markSupport == null || markSupport.getComments().isEmpty())) {
add(newFragment("Content is identical", false));
} else {
add(new TextDiffPanel(CONTENT_ID, projectModel, requestModel, change, diffMode, blameModel, markSupport));
}
} else if (change.getOldBlob().isPartial() || change.getNewBlob().isPartial()) {
add(newFragment("File is too large to be loaded.", true));
} else if (change.getOldBlob().getMediaType().equals(change.getNewBlob().getMediaType())) {
Panel diffPanel = null;
for (DiffRenderer renderer: GitPlex.getExtensions(DiffRenderer.class)) {
diffPanel = renderer.render(CONTENT_ID, change.getNewBlob().getMediaType(), change);
if (diffPanel != null)
break;
}
if (diffPanel != null)
add(diffPanel);
else
add(newFragment("Binary file.", false));
} else {
add(newFragment("Binary file.", false));
}
}
}
示例14: getOldBlobIdent
import org.eclipse.jgit.diff.DiffEntry.ChangeType; //导入依赖的package包/类
public static BlobIdent getOldBlobIdent(DiffEntry diffEntry, String oldRev) {
BlobIdent blobIdent;
if (diffEntry.getChangeType() != ChangeType.ADD) {
blobIdent = new BlobIdent(oldRev, diffEntry.getOldPath(), diffEntry.getOldMode().getBits());
} else {
blobIdent = new BlobIdent(oldRev, null, null);
}
return blobIdent;
}
示例15: getNewBlobIdent
import org.eclipse.jgit.diff.DiffEntry.ChangeType; //导入依赖的package包/类
public static BlobIdent getNewBlobIdent(DiffEntry diffEntry, String newRev) {
BlobIdent blobIdent;
if (diffEntry.getChangeType() != ChangeType.DELETE) {
blobIdent = new BlobIdent(newRev, diffEntry.getNewPath(), diffEntry.getNewMode().getBits());
} else {
blobIdent = new BlobIdent(newRev, null, null);
}
return blobIdent;
}