瀏覽代碼

Expose conflicting files in CheckoutConflictException

Change-Id: I5b3b7b0633354d5ccf0c6c320c0df9c93fdf8eeb
Signed-off-by: Ned Twigg <ned.twigg@diffplug.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
tags/v4.4.0.201605041135-m1
Ned Twigg 10 年之前
父節點
當前提交
32a5993227

+ 2
- 0
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java 查看文件

fail("didn't get the expected exception"); fail("didn't get the expected exception");
} catch (CheckoutConflictException e) { } catch (CheckoutConflictException e) {
assertConflict("foo"); assertConflict("foo");
assertEquals("foo", e.getConflictingFiles()[0]);
assertWorkDir(mkmap("foo", "bar", "other", "other")); assertWorkDir(mkmap("foo", "bar", "other", "other"));
assertIndex(mk("other")); assertIndex(mk("other"));
} }
assertWorkDir(mkmap("a", "a", "b/c", "b/c", "d", "d", "e/f", assertWorkDir(mkmap("a", "a", "b/c", "b/c", "d", "d", "e/f",
"e/f", "e/g", "e/g3")); "e/f", "e/g", "e/g3"));
assertConflict("e/g"); assertConflict("e/g");
assertEquals("e/g", e.getConflictingFiles()[0]);
} }
} }



+ 13
- 0
org.eclipse.jgit/src/org/eclipse/jgit/errors/CheckoutConflictException.java 查看文件

public class CheckoutConflictException extends IOException { public class CheckoutConflictException extends IOException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;


private final String[] conflicting;

/** /**
* Construct a CheckoutConflictException for the specified file * Construct a CheckoutConflictException for the specified file
* *
*/ */
public CheckoutConflictException(String file) { public CheckoutConflictException(String file) {
super(MessageFormat.format(JGitText.get().checkoutConflictWithFile, file)); super(MessageFormat.format(JGitText.get().checkoutConflictWithFile, file));
conflicting = new String[] { file };
} }


/** /**
*/ */
public CheckoutConflictException(String[] files) { public CheckoutConflictException(String[] files) {
super(MessageFormat.format(JGitText.get().checkoutConflictWithFiles, buildList(files))); super(MessageFormat.format(JGitText.get().checkoutConflictWithFiles, buildList(files)));
conflicting = files;
}

/**
* @return the relative paths of the conflicting files (relative to the
* working directory root).
* @since 4.4
*/
public String[] getConflictingFiles() {
return conflicting;
} }


private static String buildList(String[] files) { private static String buildList(String[] files) {

Loading…
取消
儲存