Skip to content
This repository has been archived by the owner on Sep 20, 2020. It is now read-only.

Commit

Permalink
Issue 20: Make IndexBuilder print "M file" when adding modified files
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
  • Loading branch information
jonas committed Sep 14, 2009
1 parent 215bbba commit 3870a99
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/org/nbgit/client/IndexBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
public class IndexBuilder extends ClientBuilder {

private static String ADDING = "A %s"; // NOI18N
private static String UPDATING = "M %s"; // NOI18N
private static String DELETING = "D %s"; // NOI18N
private static String MOVING = "R %s -> %s"; // NOI18N
private final GitIndex index;
Expand All @@ -67,7 +68,8 @@ public static IndexBuilder create(File workDir) throws IOException {
}

public IndexBuilder add(File file) throws IOException {
log(ADDING, file);
String action = index.getEntry(toPath(file)) == null ? ADDING : UPDATING;
log(action, file);
GitIndex.Entry entry = index.add(repository.getWorkDir(), file);
entry.setAssumeValid(false);
return this;
Expand Down
11 changes: 11 additions & 0 deletions test/unit/data/generators/org.nbgit.client.IndexBuilderTest
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,14 @@ EOF
goldendata "$(git ls-files -s)"

end

describe testLog

index <<EOF
100644 d2d902de084b7dbc96a762bd05bfc80f9b096a97 0 modified
EOF

files modified
testfiles .git/index modified

end
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
modified
2 changes: 2 additions & 0 deletions test/unit/src/org/nbgit/client/IndexBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public void testMoveSupportsExecutable() throws Exception {
public void testLog() throws Exception {
String[] expectedMessages = {
"A add",
"M modified",
"D delete",
"R from -> to"
};
Expand All @@ -147,6 +148,7 @@ public void testLog() throws Exception {
IndexBuilder.create(repository).
log(logger).
add(toWorkDirFile("add")).
add(toWorkDirFile("modified")).
delete(toWorkDirFile("delete")).
move(toWorkDirFile("from"), toWorkDirFile("to"));
assertEquals(expectedMessages.length, loggerMessages.size());
Expand Down

0 comments on commit 3870a99

Please sign in to comment.