Skip to content
Snippets Groups Projects
Commit fc21f671 authored by Florian Heck's avatar Florian Heck
Browse files

refactoring of blame line parsing

parent 72309f37
No related branches found
No related tags found
No related merge requests found
......@@ -60,5 +60,6 @@ public class DummyCommit extends Commit {
private void setterWarning() {
LOG.warning(() -> "Ignoring a setter call on the DummyCommit for " + repo);
// TODO gets called often while parsing blame lines, maybe change level
}
}
......@@ -34,6 +34,7 @@ public class Repository {
private static final String COMMITTER_TIME = "committer-time";
private static final String COMMITTER_TZ = "committer-tz";
private static final String FILENAME = "filename";
private static final String MESSAGE = "summary";
// The type returned for commits by 'git cat-file -t".
private static final String TYPE_COMMIT = "commit";
......@@ -361,17 +362,9 @@ public class Repository {
} break;
case AUTHOR_TIME:
authorInstant = Instant.ofEpochSecond(lineScanner.nextLong());
if (authorTZ != null) {
commit.setAuthorTime(OffsetDateTime.ofInstant(authorInstant, authorTZ));
}
break;
case AUTHOR_TZ:
authorTZ = ZoneId.of(lineScanner.next());
if (authorInstant != null) {
commit.setAuthorTime(OffsetDateTime.ofInstant(authorInstant, authorTZ));
}
break;
case COMMITTER:
commit.setCommitter(lineScanner.nextLine().trim());
......@@ -382,25 +375,26 @@ public class Repository {
} break;
case COMMITTER_TIME:
committerInstant = Instant.ofEpochSecond(lineScanner.nextLong());
if (committerTZ != null) {
commit.setCommitterTime(OffsetDateTime.ofInstant(committerInstant, committerTZ));
}
break;
case COMMITTER_TZ:
committerTZ = ZoneId.of(lineScanner.next());
if (committerInstant != null) {
commit.setCommitterTime(OffsetDateTime.ofInstant(committerInstant, committerTZ));
}
break;
case FILENAME:
commitFile = dir.toPath().resolve(Paths.get(lineScanner.nextLine().trim())).toFile();
break;
case MESSAGE:
commit.setMessage(lineScanner.nextLine().trim());
break;
default:
other.put(headerKey, lineScanner.nextLine().trim());
}
}
if (authorInstant != null && authorTZ != null) {
commit.setAuthorTime(OffsetDateTime.ofInstant(authorInstant, authorTZ));
}
if (committerInstant != null && committerTZ != null) {
commit.setCommitterTime(OffsetDateTime.ofInstant(committerInstant, committerTZ));
}
// Read the line starting with a TAB and store it in a BlameLine along with its commit.
BlameLine bLine;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment