The Unified and Autonomous Development Platform
Refactor Commit and the command to list branch head commit.
robin shine85403e7d0824
diff --git a/commons.git/src/main/java/com/pmease/commons/git/BriefCommit.java b/commons.git/src/main/java/com/pmease/commons/git/BriefCommit.javaindex 4e44dc9391..104c8691ac 100644--- a/commons.git/src/main/java/com/pmease/commons/git/BriefCommit.java+++ b/commons.git/src/main/java/com/pmease/commons/git/BriefCommit.java@@ -3,6 +3,7 @@ package com.pmease.commons.git;import static com.google.common.base.Preconditions.checkNotNull;import java.io.Serializable;+import java.util.Date;import org.eclipse.jgit.lib.PersonIdent;@@ -13,17 +14,17 @@ public class BriefCommit implements Serializable {private final String hash;+ private final String messageSummary;+private final PersonIdent committer;private final PersonIdent author;- private final String subject;-- public BriefCommit(String hash, PersonIdent committer, PersonIdent author, String subject) {+ public BriefCommit(String hash, PersonIdent committer, PersonIdent author, String messageSummary) {this.hash = checkNotNull(hash, "hash");this.committer = checkNotNull(committer, "committer");this.author = checkNotNull(author, "author");- this.subject = checkNotNull(subject, "subject");+ this.messageSummary = checkNotNull(messageSummary, "messageSummary");}public String getHash() {@@ -38,8 +39,8 @@ public class BriefCommit implements Serializable {return author;}- public String getSubject() {- return subject;+ public String getMessageSummary() {+ return messageSummary;}@Override@@ -62,8 +63,32 @@ public class BriefCommit implements Serializable {.add("hash", hash).add("committer", committer.getName()).add("date", committer.getWhen())- .add("subject", subject)+ .add("messageSummary", messageSummary).toString();}-++ public static class Builder {++ public String hash;++ public String committerName;++ public String committerEmail;++ public Date committerDate;++ public String authorName;++ public Date authorDate;++ public String authorEmail;++ public String messageSummary;++ public BriefCommit build() {+ PersonIdent committer = GitUtils.newPersonIdent(committerName, committerEmail, committerDate);+ PersonIdent author = GitUtils.newPersonIdent(authorName, authorEmail, authorDate);+ return new BriefCommit(hash, committer, author, messageSummary);+ }+ }}diff --git a/commons.git/src/main/java/com/pmease/commons/git/Commit.java b/commons.git/src/main/java/com/pmease/commons/git/Commit.javaindex 91d572e244..8c1734a685 100644--- a/commons.git/src/main/java/com/pmease/commons/git/Commit.java+++ b/commons.git/src/main/java/com/pmease/commons/git/Commit.java@@ -3,121 +3,68 @@ package com.pmease.commons.git;import static com.google.common.base.Preconditions.checkNotNull;import java.util.ArrayList;-import java.util.Collections;import java.util.List;import javax.annotation.Nullable;-import org.apache.commons.lang3.StringUtils;import org.eclipse.jgit.lib.PersonIdent;-import com.google.common.base.Strings;-import com.google.common.collect.Lists;-@SuppressWarnings("serial")public class Commit extends BriefCommit {-- private final String body;++ private final String messageBody;private final String note;private final List<String> parentHashes;-- private final List<Change> fileChanges;- public static class Builder {- String hash;- String subject;- String body;- String note;- PersonIdent author;- PersonIdent committer;- List<String> parents = Lists.newArrayList();- List<Change> changes = Lists.newArrayList();-- public Builder hash(String hash) {- this.hash = hash;- return this;- }-- public Builder subject(String subject) {- this.subject = subject;- return this;- }-- public Builder body(String body) {- if (!StringUtils.isBlank(body))- this.body = body;-- return this;- }-- public Builder note(String note) {- this.note = note;- return this;- }-- public Builder author(PersonIdent author) {- this.author = author;- return this;- }-- public Builder committer(PersonIdent committer) {- this.committer = committer;- return this;- }-- public Builder parents(List<String> parents) {- this.parents = parents;- return this;- }-- public Builder changes(List<Change> changes) {- this.changes = changes;- return this;- }-- public Commit build() {- return new Commit(- hash, committer, author, subject,- body, note, parents, changes);- }- }-- public static Builder builder() {- return new Builder();- }-- public Commit(String hash, PersonIdent committer, PersonIdent author,- String subject, @Nullable String body,- @Nullable String note, List<String> parentHashes,- List<Change> fileChanges) {- super(hash, committer, author, subject);+ public Commit(String hash, PersonIdent committer, PersonIdent author, String messageSummary,+ @Nullable String messageBody, List<String> parentHashes, @Nullable String note) {+ super(hash, committer, author, messageSummary);- this.body = body;+ this.parentHashes = checkNotNull(parentHashes, "parentHashes");+ this.messageBody = messageBody;this.note = note;- this.parentHashes = new ArrayList<>(checkNotNull(parentHashes, "parentHashes"));- this.fileChanges = new ArrayList<>(checkNotNull(fileChanges, "fileChanges"));}public String getMessage() {- return Strings.isNullOrEmpty(body) ? getSubject() : getSubject() + "\n" + body;+ if (messageBody != null)+ return getMessageSummary() + "\n\n" + messageBody;+ else+ return getMessageSummary();}- public @Nullable String getMessageBody() {- return body;- }-- public @Nullable String getNote() {+ @Nullable+ public String getNote() {return note;}public List<String> getParentHashes() {- return Collections.unmodifiableList(parentHashes);+ return parentHashes;}- public List<Change> getFileChanges() {- return Collections.unmodifiableList(fileChanges);+ @Nullable+ public String getMessageBody() {+ return messageBody;}+ public static class Builder extends BriefCommit.Builder {++ public String messageBody;++ public List<String> parentHashes = new ArrayList<>();++ public String note;++ public Commit build() {+ BriefCommit briefCommit = super.build();+ return new Commit(briefCommit.getHash(), briefCommit.getCommitter(), briefCommit.getAuthor(),+ briefCommit.getMessageSummary(), messageBody, parentHashes, note);+ }+ }++ public static Builder builder() {+ return new Builder();+ }+}diff --git a/commons.git/src/main/java/com/pmease/commons/git/Git.java b/commons.git/src/main/java/com/pmease/commons/git/Git.javaindex fe5220512d..d98a32f7cc 100644--- a/commons.git/src/main/java/com/pmease/commons/git/Git.java+++ b/commons.git/src/main/java/com/pmease/commons/git/Git.java@@ -38,7 +38,8 @@ import com.pmease.commons.git.command.InitCommand;import com.pmease.commons.git.command.IsAncestorCommand;import com.pmease.commons.git.command.IsBinaryCommand;import com.pmease.commons.git.command.IsTreeLinkCommand;-import com.pmease.commons.git.command.ListBranchesCommand;+import com.pmease.commons.git.command.ListBranchCommand;+import com.pmease.commons.git.command.ListHeadCommitCommand;import com.pmease.commons.git.command.ListChangedFilesCommand;import com.pmease.commons.git.command.ListFileChangesCommand;import com.pmease.commons.git.command.ListSubModulesCommand;@@ -89,7 +90,7 @@ public class Git implements Serializable {* this git object*/public Git createBranch(String branchName, String commitHash) {- if (new ListBranchesCommand(repoDir).call().containsKey(branchName))+ if (new ListBranchCommand(repoDir).call().contains(branchName))throw new GeneralException(String.format("Branch %s already exists.", branchName));new UpdateRefCommand(repoDir).refName(Git.REFS_HEADS + branchName).revision(commitHash)@@ -452,12 +453,22 @@ public class Git implements Serializable {* List all local branches in git repository.* @return- * a map from branch name to head commit+ * a collection of branch names*/- public Map<String, String> listBranches() {- return new ListBranchesCommand(repoDir).call();+ public Collection<String> listBranches() {+ return new ListBranchCommand(repoDir).call();}+ /**+ * List head commits of all local branches.++ * @return+ * a map from branch name to brief head commit+ */+ public Map<String, BriefCommit> listHeadCommits() {+ return new ListHeadCommitCommand(repoDir).call();+ }+public Collection<String> listTags() {return new ListTagsCommand(repoDir).call();}diff --git a/commons.git/src/main/java/com/pmease/commons/git/GitUtils.java b/commons.git/src/main/java/com/pmease/commons/git/GitUtils.javaindex af30acb197..6b6f1ba480 100644--- a/commons.git/src/main/java/com/pmease/commons/git/GitUtils.java+++ b/commons.git/src/main/java/com/pmease/commons/git/GitUtils.java@@ -3,6 +3,8 @@ package com.pmease.commons.git;import java.util.Date;import java.util.regex.Pattern;+import javax.annotation.Nullable;+import org.apache.commons.lang3.StringUtils;import org.eclipse.jgit.lib.FileMode;import org.eclipse.jgit.lib.PersonIdent;@@ -10,6 +12,9 @@ import org.eclipse.jgit.util.SystemReader;import com.google.common.base.Objects;import com.google.common.base.Preconditions;+import com.google.common.base.Splitter;+import com.google.common.base.Strings;+import com.google.common.collect.Iterables;public class GitUtils {@@ -52,4 +57,48 @@ public class GitUtils {SystemReader.getInstance().getTimezone(when.getTime()));}+ /**+ * Parse the original git raw date to Java date. The raw git date is in+ * unix timestamp with timezone like:+ * 1392312299 -0800+ *+ * @param input the input raw date string+ * @return Java date+ */+ public static Date parseRawDate(String input) {+ String[] pieces = Iterables.toArray(Splitter.on(" ").split(input), String.class);+ return new Date(Long.valueOf(pieces[0]) * 1000L);+ }++ /**+ * Parse the raw user information into PersonIdent object, the raw information+ * should be in format <code>[name] [<email>] [epoch timezone]</code>, for+ * example:+ *+ * Jacob Thornton <[email protected]> 1328060294 -0800+ *+ * @param raw+ * @return+ */+ public static @Nullable PersonIdent parsePersonIdent(String raw) {+ if (Strings.isNullOrEmpty(raw))+ return null;++ int pos1 = raw.indexOf('<');+ if (pos1 <= 0)+ throw new IllegalArgumentException("Raw " + raw);++ String name = raw.substring(0, pos1 - 1);++ int pos2 = raw.indexOf('>');+ if (pos2 <= 0)+ throw new IllegalArgumentException("Raw " + raw);++ String time = raw.substring(pos2 + 1).trim();+ Date when = parseRawDate(time);++ String email = raw.substring(pos1 + 1, pos2 - 1);++ return newPersonIdent(name, email, when);+ }}diff --git a/commons.git/src/main/java/com/pmease/commons/git/command/ListBranchesCommand.java b/commons.git/src/main/java/com/pmease/commons/git/command/ListBranchCommand.javasimilarity index 55%rename from commons.git/src/main/java/com/pmease/commons/git/command/ListBranchesCommand.javarename to commons.git/src/main/java/com/pmease/commons/git/command/ListBranchCommand.javaindex 0c6414c80e..0618b0583c 100644--- a/commons.git/src/main/java/com/pmease/commons/git/command/ListBranchesCommand.java+++ b/commons.git/src/main/java/com/pmease/commons/git/command/ListBranchCommand.java@@ -1,9 +1,8 @@package com.pmease.commons.git.command;import java.io.File;-import java.util.HashMap;-import java.util.Map;-import java.util.StringTokenizer;+import java.util.ArrayList;+import java.util.Collection;import org.apache.commons.lang3.StringUtils;import org.slf4j.Logger;@@ -12,28 +11,26 @@ import org.slf4j.LoggerFactory;import com.pmease.commons.util.execution.Commandline;import com.pmease.commons.util.execution.LineConsumer;-public class ListBranchesCommand extends GitCommand<Map<String, String>> {+public class ListBranchCommand extends GitCommand<Collection<String>> {- private static final Logger logger = LoggerFactory.getLogger(ListBranchesCommand.class);+ private static final Logger logger = LoggerFactory.getLogger(ListBranchCommand.class);- public ListBranchesCommand(File repoDir) {+ public ListBranchCommand(File repoDir) {super(repoDir);}@Override- public Map<String, String> call() {+ public Collection<String> call() {Commandline cmd = cmd();- cmd.addArgs("branch", "--verbose", "--no-abbrev");+ cmd.addArgs("branch");- final Map<String, String> branches = new HashMap<String, String>();+ final Collection<String> branches = new ArrayList<String>();cmd.execute(new LineConsumer() {@Overridepublic void consume(String line) {- line = StringUtils.stripStart(line, "*").trim();- StringTokenizer tokenizer = new StringTokenizer(line);- branches.put(tokenizer.nextToken(), tokenizer.nextToken());+ branches.add(StringUtils.stripStart(line, "*").trim());}}, new LineConsumer() {diff --git a/commons.git/src/main/java/com/pmease/commons/git/command/ListHeadCommitCommand.java b/commons.git/src/main/java/com/pmease/commons/git/command/ListHeadCommitCommand.javanew file mode 100644index 0000000000..943d7bbe5a--- /dev/null+++ b/commons.git/src/main/java/com/pmease/commons/git/command/ListHeadCommitCommand.java@@ -0,0 +1,90 @@+package com.pmease.commons.git.command;++import java.io.File;+import java.util.HashMap;+import java.util.Iterator;+import java.util.Map;++import org.eclipse.jgit.lib.PersonIdent;+import org.slf4j.Logger;+import org.slf4j.LoggerFactory;++import com.google.common.base.Splitter;+import com.pmease.commons.git.BriefCommit;+import com.pmease.commons.git.GitUtils;+import com.pmease.commons.util.execution.Commandline;+import com.pmease.commons.util.execution.LineConsumer;++public class ListHeadCommitCommand extends GitCommand<Map<String, BriefCommit>> {++ private static final Logger logger = LoggerFactory.getLogger(ListHeadCommitCommand.class);++ private static final String SEPARATOR = "#|@";++ public ListHeadCommitCommand(File repoDir) {+ super(repoDir);+ }++ public ListHeadCommitCommand(File repoDir, Map<String, String> environments) {+ super(repoDir, environments);+ }++ @Override+ public Map<String, BriefCommit> call() {+ Commandline cmd = cmd();++ cmd.addArgs("for-each-ref");++ String format =+ "%(refname:short)" + SEPARATOR ++ "%(objectname)" + SEPARATOR ++ "%(committername)" + SEPARATOR + "%(committeremail)" + SEPARATOR + "%(committerdate:raw)" + SEPARATOR ++ "%(authorname)" + SEPARATOR + "%(authoremail)" + SEPARATOR + "%(authordate:raw)" ++ "%09%(contents:subject)";+ cmd.addArgs("--format=" + format);++ cmd.addArgs("refs/heads/");++ final Map<String, BriefCommit> branches = new HashMap<>();++ cmd.execute(new LineConsumer() {++ private String parseEmail(String mail) {+ if (mail.charAt(0) == '<')+ mail = mail.substring(1, mail.length() - 1);++ return mail;+ }++ @Override+ public void consume(String line) {+ int pos = line.indexOf('\t');+ String first = line.substring(0, pos);+ String subject = line.substring(pos + 1);+ Iterator<String> iterator = Splitter.on(SEPARATOR).split(first).iterator();++ String refname = iterator.next();+ String sha = iterator.next();++ PersonIdent committer = GitUtils.newPersonIdent(iterator.next(),+ parseEmail(iterator.next()), GitUtils.parseRawDate(iterator.next()));+ PersonIdent author = GitUtils.newPersonIdent(iterator.next(),+ parseEmail(iterator.next()), GitUtils.parseRawDate(iterator.next()));++ BriefCommit commit = new BriefCommit(sha, committer, author, subject);+ branches.put(refname, commit);+ }++ }, new LineConsumer() {++ @Override+ public void consume(String line) {+ logger.error(line);+ }++ });++ return branches;+ }++}diff --git a/commons.git/src/main/java/com/pmease/commons/git/command/LogCommand.java b/commons.git/src/main/java/com/pmease/commons/git/command/LogCommand.javaindex 114ab29122..36c6f696ac 100644--- a/commons.git/src/main/java/com/pmease/commons/git/command/LogCommand.java+++ b/commons.git/src/main/java/com/pmease/commons/git/command/LogCommand.java@@ -2,17 +2,14 @@ package com.pmease.commons.git.command;import java.io.File;import java.util.ArrayList;-import java.util.Date;import java.util.List;+import java.util.concurrent.atomic.AtomicBoolean;import org.apache.commons.lang3.StringUtils;-import org.joda.time.format.DateTimeFormat;-import org.joda.time.format.DateTimeFormatter;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import com.pmease.commons.git.Commit;-import com.pmease.commons.git.Change;import com.pmease.commons.git.GitUtils;import com.pmease.commons.util.execution.Commandline;import com.pmease.commons.util.execution.LineConsumer;@@ -21,8 +18,6 @@ public class LogCommand extends GitCommand<List<Commit>> {private static final Logger logger = LoggerFactory.getLogger(LogCommand.class);- private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss Z");-private String fromRev;private String toRev;@@ -76,8 +71,8 @@ public class LogCommand extends GitCommand<List<Commit>> {"--format=*** commit_begin ***%n%B%n*** commit_message_end ***%n%N"+ "*** commit_note_end ***%nhash:%H%nauthor:%aN%nauthorEmail:%aE%n"+ "committerEmail:%cE%ncommitter:%cN%nparents:%P%ncommitterDate:%cd %n"- + "authorDate:%ad %n*** commit_info_end ***",- "--raw", "--find-renames", "--date=iso");+ + "authorDate:%ad %n",+ "--date=raw");if (fromRev != null) {if (toRev != null)cmd.addArgs(fromRev + ".." + toRev);@@ -101,51 +96,41 @@ public class LogCommand extends GitCommand<List<Commit>> {final List<Commit> commits = new ArrayList<>();- final CommitBuilder commitBuilder = new CommitBuilder();+ final Commit.Builder commitBuilder = Commit.builder();- final boolean[] commitNoteBlock = new boolean[1];- final boolean[] commitMessageBlock = new boolean[1];- final boolean[] rawBlock = new boolean[1];+ final AtomicBoolean commitMessageBlock = new AtomicBoolean();+ final AtomicBoolean commitNoteBlock = new AtomicBoolean();cmd.execute(new LineConsumer() {@Overridepublic void consume(String line) {if (line.equals("*** commit_begin ***")) {- if (commitBuilder.hash != null) {+ if (commitBuilder.hash!= null) {commits.add(commitBuilder.build());commitBuilder.parentHashes.clear();- commitBuilder.fileChanges.clear();- commitBuilder.summary = null;- commitBuilder.message = null;+ commitBuilder.messageSummary = null;+ commitBuilder.messageBody = null;commitBuilder.note = null;}- commitMessageBlock[0] = true;- rawBlock[0] = false;+ commitMessageBlock.set(true);} else if (line.equals("*** commit_message_end ***")) {- commitMessageBlock[0] = false;- commitNoteBlock[0] = true;+ commitMessageBlock.set(false);+ commitNoteBlock.set(true);} else if (line.equals("*** commit_note_end ***")) {- commitNoteBlock[0] = false;- } else if (line.equals("*** commit_info_end ***")) {- rawBlock[0] = true;- } else if (commitMessageBlock[0]) {- if (commitBuilder.summary == null)- commitBuilder.summary = line;- else if (commitBuilder.message == null)- commitBuilder.message = line;+ commitNoteBlock.set(false);+ } else if (commitMessageBlock.get()) {+ if (commitBuilder.messageSummary == null)+ commitBuilder.messageSummary = line;+ else if (commitBuilder.messageBody == null)+ commitBuilder.messageBody = line;else- commitBuilder.message += "\n" + line;- } else if (commitNoteBlock[0]) {+ commitBuilder.messageBody += "\n" + line;+ } else if (commitNoteBlock.get()) {if (commitBuilder.note == null)commitBuilder.note = line;elsecommitBuilder.note += "\n" + line;- } else if (rawBlock[0]) {- if (line.startsWith(":"))- commitBuilder.fileChanges.add(Change.parseRawLine(line));- } else if (line.startsWith("subject:")) {- commitBuilder.summary = line.substring("subject:".length());} else if (line.startsWith("hash:")) {commitBuilder.hash = line.substring("hash:".length());} else if (line.startsWith("author:")) {@@ -153,9 +138,9 @@ public class LogCommand extends GitCommand<List<Commit>> {} else if (line.startsWith("committer:")) {commitBuilder.committerName = line.substring("committer:".length());} else if (line.startsWith("authorDate:")) {- commitBuilder.authorDate = DATE_FORMATTER.parseDateTime(line.substring("authorDate:".length()).trim()).toDate();+ commitBuilder.authorDate = GitUtils.parseRawDate(line.substring("authorDate:".length()).trim());} else if (line.startsWith("committerDate:")) {- commitBuilder.committerDate = DATE_FORMATTER.parseDateTime(line.substring("committerDate:".length()).trim()).toDate();+ commitBuilder.committerDate = GitUtils.parseRawDate(line.substring("committerDate:".length()).trim());} else if (line.startsWith("authorEmail:")) {commitBuilder.authorEmail = line.substring("authorEmail:".length());} else if (line.startsWith("committerEmail:")) {@@ -180,43 +165,5 @@ public class LogCommand extends GitCommand<List<Commit>> {return commits;}-- private static class CommitBuilder {-- private Date committerDate;-- private Date authorDate;-- private String authorName;-- private String committerName;-- private String authorEmail;-- private String committerEmail;-- private String hash;-- private String summary;-- private String message;-- private String note;-- private List<String> parentHashes = new ArrayList<>();-- private List<Change> fileChanges = new ArrayList<>();-- private Commit build() {- return new Commit(- hash,- GitUtils.newPersonIdent(committerName, committerEmail, committerDate),- GitUtils.newPersonIdent(authorName, authorEmail, authorDate),- summary.trim(),- StringUtils.isNotBlank(message)?message.trim():null,- StringUtils.isNotBlank(note)?note.trim():null,- parentHashes, fileChanges);- }- }}diff --git a/commons.git/src/test/java/com/pmease/commons/git/GitTest.java b/commons.git/src/test/java/com/pmease/commons/git/GitTest.javaindex 265d65a426..4fb15f23b0 100644--- a/commons.git/src/test/java/com/pmease/commons/git/GitTest.java+++ b/commons.git/src/test/java/com/pmease/commons/git/GitTest.java@@ -7,6 +7,7 @@ import static com.pmease.commons.git.Change.Status.RENAMED;import static com.pmease.commons.git.Change.Status.UNCHANGED;import static org.junit.Assert.assertEquals;+import java.io.File;import java.util.List;import org.junit.Test;@@ -83,4 +84,11 @@ public class GitTest extends AbstractGitTest {assertEquals(RENAMED, diffs.get(4).getStatus());}+ @Test+ public void test() {+ Git git = new Git(new File("w:\\linux\\.git"));+ long time = System.currentTimeMillis();+ git.log("master~1000", "master", null, 0, 0);+ System.out.println(System.currentTimeMillis()-time);+ }}diff --git a/commons.git/src/test/java/com/pmease/commons/git/command/LogCommandTest.java b/commons.git/src/test/java/com/pmease/commons/git/command/LogCommandTest.javaindex 89357644ce..ae490d4bc3 100644--- a/commons.git/src/test/java/com/pmease/commons/git/command/LogCommandTest.java+++ b/commons.git/src/test/java/com/pmease/commons/git/command/LogCommandTest.java@@ -9,7 +9,6 @@ import org.junit.Test;import com.pmease.commons.git.AbstractGitTest;import com.pmease.commons.git.Commit;-import com.pmease.commons.git.Change;import com.pmease.commons.git.Git;public class LogCommandTest extends AbstractGitTest {@@ -38,12 +37,9 @@ public class LogCommandTest extends AbstractGitTest {List<Commit> commits = bareGit.log(null, "master", null, 0, 0);assertEquals(commits.size(), 6);- assertEquals(commits.get(0).getSubject(), "add dir/file");+ assertEquals(commits.get(0).getMessageSummary(), "add dir/file");assertEquals(commits.get(0).getMessage(), "add dir/file\nadd dir/file to test files under a directory");assertEquals("hello\nworld", commits.get(0).getNote());- assertEquals(commits.get(0).getFileChanges().size(), 2);- assertEquals(commits.get(0).getFileChanges().get(0).getNewPath(), "dir/file");- assertEquals(commits.get(0).getFileChanges().get(0).getStatus(), Change.Status.ADDED);assertEquals(commits.get(0).getParentHashes().size(), 1);assertEquals(commits.get(0).getParentHashes().iterator().next(), commits.get(1).getHash());@@ -67,22 +63,4 @@ public class LogCommandTest extends AbstractGitTest {assertEquals(git.showRevision(commits.get(1).getHash()).getHash(), commits.get(1).getHash());}- @Test- public void shouldHandleRenameAndCopyCorrectly() {- addFileAndCommit("a", "1111\n2222\n3333\n", "add a");- addFile("a", "1111\n2222\n3333\n4444\n");- addFile("a2", "1111\n2222\n3333\n4444\n");- commit("copy a to a2");-- addFileAndCommit("b", "1111\n2222\n3333\n4444\n", "add b");-- rm("b");- addFileAndCommit("b2", "1111\n2222\n3333\n4444\n", "move b to b2");-- List<Commit> commits = git.log("master~3", "master", null, 0, 0);- Change change = commits.get(0).getFileChanges().get(0);- assertEquals("RENAMED\tb->b2", change.toString());- change = commits.get(2).getFileChanges().get(1);- assertEquals("ADDED\ta2", change.toString());- }}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultRepositoryManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultRepositoryManager.javaindex 6b226f7e4e..51627d1f66 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultRepositoryManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultRepositoryManager.java@@ -19,6 +19,7 @@ import org.slf4j.Logger;import org.slf4j.LoggerFactory;import com.google.common.base.Preconditions;+import com.pmease.commons.git.BriefCommit;import com.pmease.commons.git.Git;import com.pmease.commons.hibernate.Sessional;import com.pmease.commons.hibernate.Transactional;@@ -201,7 +202,7 @@ public class DefaultRepositoryManager implements RepositoryManager {logger.debug("Syncing branches of repository '{}'...", repository);Map<String, Branch> branchesInDB = new HashMap<String, Branch>();- Map<String, String> branchesInGit = repository.git().listBranches();+ Map<String, BriefCommit> branchesInGit = repository.git().listHeadCommits();for (Iterator<Branch> it = repository.getBranches().iterator(); it.hasNext();) {Branch branch = it.next();if (branchesInGit.containsKey(branch.getName())) {@@ -212,17 +213,17 @@ public class DefaultRepositoryManager implements RepositoryManager {}}- for (Map.Entry<String, String> entry: branchesInGit.entrySet()) {+ for (Map.Entry<String, BriefCommit> entry: branchesInGit.entrySet()) {Branch branch = branchesInDB.get(entry.getKey());if (branch == null) {branch = new Branch();branch.setName(entry.getKey());- branch.setHeadCommitHash(entry.getValue());+ branch.setHeadCommitHash(entry.getValue().getHash());branch.setRepository(repository);repository.getBranches().add(branch);branchManager.save(branch);} else if (!branch.getHeadCommitHash().equals(entry.getValue())) {- branch.setHeadCommitHash(entry.getValue());+ branch.setHeadCommitHash(entry.getValue().getHash());branchManager.save(branch);}}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/GitPlexMappings.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/GitPlexMappings.javaindex f2f509269e..3c6228b6a5 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/GitPlexMappings.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/GitPlexMappings.java@@ -36,7 +36,6 @@ import com.pmease.gitplex.web.page.repository.admin.GeneralSettingPage;import com.pmease.gitplex.web.page.repository.admin.PermissionSettingPage;import com.pmease.gitplex.web.page.repository.admin.gatekeeper.GateKeeperPage;import com.pmease.gitplex.web.page.repository.admin.integrationpolicy.IntegrationPolicyPage;-import com.pmease.gitplex.web.page.repository.code.blame.BlobBlamePage;import com.pmease.gitplex.web.page.repository.code.blob.RepoBlobPage;import com.pmease.gitplex.web.page.repository.code.blob.renderer.RawBlobResourceReference;import com.pmease.gitplex.web.page.repository.code.branches.BranchComparePage;@@ -45,7 +44,6 @@ import com.pmease.gitplex.web.page.repository.code.commit.RepoCommitPage;import com.pmease.gitplex.web.page.repository.code.commits.RepoCommitsPage;import com.pmease.gitplex.web.page.repository.code.contributors.ContributorsPage;import com.pmease.gitplex.web.page.repository.code.tags.GitArchiveResourceReference;-import com.pmease.gitplex.web.page.repository.code.tags.TagsPage;import com.pmease.gitplex.web.page.repository.code.tree.RepoTreePage;import com.pmease.gitplex.web.page.repository.pullrequest.ClosedRequestsPage;import com.pmease.gitplex.web.page.repository.pullrequest.NewRequestPage;@@ -142,8 +140,6 @@ public class GitPlexMappings extends CompoundRequestMapper {"${user}/${repo}/tree", RepoTreePage.class));add(new PageParameterAwareMountedMapper("${user}/${repo}/blob", RepoBlobPage.class));- add(new PageParameterAwareMountedMapper(- "${user}/${repo}/blame", BlobBlamePage.class));add(new PageParameterAwareMountedMapper("${user}/${repo}/commit", RepoCommitPage.class));add(new PageParameterAwareMountedMapper(@@ -153,8 +149,6 @@ public class GitPlexMappings extends CompoundRequestMapper {add(new PageParameterAwareMountedMapper("${user}/${repo}/branches",RepoBranchesPage.class));- add(new PageParameterAwareMountedMapper("${user}/${repo}/tags",- TagsPage.class));add(new PageParameterAwareMountedMapper("${user}/${repo}/pull-requests/open", OpenRequestsPage.class));diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commit/CommitMessagePanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commit/CommitMessagePanel.javaindex d3c41a788e..29154fdc88 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commit/CommitMessagePanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commit/CommitMessagePanel.java@@ -38,7 +38,7 @@ public class CommitMessagePanel extends Panel {@Overridepublic String getObject() {- return getCommit().getSubject();+ return getCommit().getMessageSummary();}}));@@ -48,7 +48,7 @@ public class CommitMessagePanel extends Panel {super.onConfigure();Commit commit = getCommit();- setVisible(!Objects.equal(commit.getSubject(), commit.getMessage()));+ setVisible(!Objects.equal(commit.getMessageSummary(), commit.getMessage()));}});@@ -58,7 +58,7 @@ public class CommitMessagePanel extends Panel {super.onConfigure();Commit commit = getCommit();- setVisible(!Objects.equal(commit.getSubject(), commit.getMessage()));+ setVisible(!Objects.equal(commit.getMessageSummary(), commit.getMessage()));}};add(detailedToggle);diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/git/GitUtils.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/git/GitUtils.javaindex 32a1e0a35e..3982e60fbc 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/git/GitUtils.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/git/GitUtils.java@@ -1,6 +1,5 @@package com.pmease.gitplex.web.git;-import java.util.Date;import java.util.List;import java.util.regex.Pattern;@@ -8,11 +7,9 @@ import javax.annotation.Nullable;import org.apache.commons.lang3.StringUtils;import org.eclipse.jgit.diff.DiffEntry;-import org.eclipse.jgit.lib.PersonIdent;import com.google.common.base.Objects;import com.google.common.base.Preconditions;-import com.google.common.base.Splitter;import com.google.common.base.Strings;import com.google.common.collect.Iterables;import com.pmease.commons.git.Commit;@@ -49,68 +46,9 @@ public class GitUtils {return abbreviateSHA(sha, SHORT_SHA_LENGTH);}- public static String getCommitSummary(Commit commit) {- return commit.getSubject();- }-public static @Nullable Commit getLastCommit(Git git, String revision, String path) {List<Commit> commits = git.log(null, revision, path, 1, 0);return Iterables.getFirst(commits, null);}- public static @Nullable String parseEmail(String mail) {- if (mail == null || mail.length() == 0)- return null;-- if (mail.charAt(0) == '<')- mail = mail.substring(1, mail.length() - 1);-- return mail;- }-- /**- * Parse the original git raw date to Java date. The raw git date is in- * unix timestamp with timezone like:- * 1392312299 -0800- *- * @param input the input raw date string- * @return Java date- */- public static Date parseRawDate(String input) {- String[] pieces = Iterables.toArray(Splitter.on(" ").split(input), String.class);- return new Date(Long.valueOf(pieces[0]) * 1000L);- }-- /**- * Parse the raw user information into UserInfo object, the raw information- * should be in format <code>[name] [<email>] [epoch timezone]</code>, for- * example:- *- * Jacob Thornton <[email protected]> 1328060294 -0800- *- * @param raw- * @return- */- public static @Nullable PersonIdent parseGitContrib(String raw) {- if (Strings.isNullOrEmpty(raw))- return null;-- int pos1 = raw.indexOf('<');- if (pos1 <= 0)- throw new IllegalArgumentException("Raw " + raw);-- String name = raw.substring(0, pos1 - 1);-- int pos2 = raw.indexOf('>');- if (pos2 <= 0)- throw new IllegalArgumentException("Raw " + raw);-- String time = raw.substring(pos2 + 1).trim();- Date when = parseRawDate(time);-- String email = raw.substring(pos1 + 1, pos2 - 1);-- return com.pmease.commons.git.GitUtils.newPersonIdent(name, email, when);- }-}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/git/command/BlameCommand.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/git/command/BlameCommand.javadeleted file mode 100644index 07251f5992..0000000000--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/git/command/BlameCommand.java+++ /dev/null@@ -1,202 +0,0 @@-package com.pmease.gitplex.web.git.command;--import java.io.File;-import java.io.IOException;-import java.util.Collections;-import java.util.Date;-import java.util.List;-import java.util.regex.Matcher;-import java.util.regex.Pattern;--import org.apache.commons.lang3.StringUtils;-import org.parboiled.common.Preconditions;-import org.slf4j.Logger;-import org.slf4j.LoggerFactory;--import com.google.common.base.Charsets;-import com.google.common.base.Objects;-import com.google.common.base.Strings;-import com.google.common.collect.Lists;-import com.google.common.io.LineProcessor;-import com.google.common.io.Resources;-import com.pmease.commons.git.command.GitCommand;-import com.pmease.commons.util.execution.Commandline;-import com.pmease.commons.util.execution.LineConsumer;-import com.pmease.gitplex.web.git.GitUtils;--public class BlameCommand extends GitCommand<List<BlameEntry>> {-- private static final Logger logger = LoggerFactory.getLogger(BlameCommand.class);-- public BlameCommand(File repoDir) {- super(repoDir);- }-- private String objectId;- private String fileName;-- public BlameCommand objectId(String objectId) {- this.objectId = objectId;- return this;- }-- public BlameCommand fileName(String fileName) {- this.fileName = fileName;- return this;- }-- @Override- public List<BlameEntry> call() {- Commandline cmd = cmd();- cmd.addArgs("blame", "--incremental");- cmd.addArgs(Preconditions.checkArgNotNull(objectId, "objectId"));- cmd.addArgs("--encoding=UTF-8");- cmd.addArgs("--", Preconditions.checkArgNotNull(fileName, "file name"));-- BlameOutputHandler out = new BlameOutputHandler();- cmd.execute(out, new LineConsumer() {-- @Override- public void consume(String line) {- logger.error(line);- }-- });-- return out.getResult();- }-- static Pattern pEntryStart = Pattern.compile("([a-z0-9]{40}) (\\d+) (\\d+) (\\d+)");-- static class BlameOutputHandler extends LineConsumer implements LineProcessor<List<BlameEntry>> {- List<BlameEntry> entries = Lists.newArrayList();- List<String> lines = Lists.newArrayList();-- BlameEntry previous;-- @Override- public void consume(String line) {- if (Strings.isNullOrEmpty(line)) {- onBlockFinished();- return;- }-- Matcher m = pEntryStart.matcher(line);- if (m.matches()) {- onBlockFinished();- }-- lines.add(line);- }-- private void onBlockFinished() {- if (lines.isEmpty())- return;-- String authorName = null; String authorEmail = null; Date authorDate = null;- String committerName = null; String committerEmail = null; Date committerDate = null;- String summary = null;- String hash = null;- int sourceLine = 0, resultLine = 0, numLines = 0;-- for (String each : lines) {- Matcher m = pEntryStart.matcher(each);- if (m.matches()) {- hash = m.group(1);- sourceLine = Integer.valueOf(m.group(2));- resultLine = Integer.valueOf(m.group(3));- numLines = Integer.valueOf(m.group(4));- } else if (each.startsWith("author ")) {- authorName = each.substring("author ".length());- } else if (each.startsWith("author-mail ")) {- authorEmail = GitUtils.parseEmail(each.substring("author-mail ".length()));- } else if (each.startsWith("author-time ")) {- long time = Long.valueOf(each.substring("author-time ".length()));- authorDate = new Date(time * 1000L);- } else if (each.startsWith("author-tz ")) {- // TODO: Add timezone info- } else if (each.startsWith("committer ")) {- committerName = each.substring("committer ".length());- } else if (each.startsWith("committer-mail ")) {- committerEmail = each.substring("committer-mail ".length());- } else if (each.startsWith("committer-time ")) {- long time = Long.valueOf(each.substring("committer-time ".length()));- committerDate = new Date(time * 1000L);- } else if (each.startsWith("committer-tz ")) {- // TODO: add timezone info- } else if (each.startsWith("summary ")) {- summary = each.substring("summary ".length());- }- }-- BlameEntry.Builder builder = BlameEntry.builder();- builder.sha(hash)- .sourceLine(sourceLine)- .resultLine(resultLine)- .numLines(numLines);-- if (Strings.isNullOrEmpty(summary)) {- // no commit summary, use previous- Preconditions.checkState(previous != null- && Objects.equal(previous.getCommit().getHash(), hash));-- builder.sha(hash)- .author(previous.getCommit().getAuthor())- .committer(previous.getCommit().getCommitter())- .summary(previous.getCommit().getSubject());- } else {- builder- .committer(com.pmease.commons.git.GitUtils.newPersonIdent(committerName, committerEmail, committerDate))- .author(com.pmease.commons.git.GitUtils.newPersonIdent(authorName, authorEmail, authorDate))- .summary(summary);- }-- BlameEntry entry = builder.build();- entries.add(entry);- previous = entry;- lines = Lists.newArrayList();- }-- @Override- public boolean processLine(String line) throws IOException {- consume(line);- return true;- }-- @Override- public List<BlameEntry> getResult() {- if (!lines.isEmpty()) {- onBlockFinished();- }-- Collections.sort(entries);- return entries;- }- }-- public static void main(String[] args) throws IOException {- BlameOutputHandler output = new BlameOutputHandler();- Resources.readLines(Resources.getResource(BlameCommand.class, "blame.txt"), Charsets.UTF_8, output);-- List<BlameEntry> entries = output.getResult();- Collections.sort(entries);-- for (BlameEntry each : entries) {- int startLine = each.getResultLine();- int numLines = each.getNumLines();- for (int i = 0; i < numLines; i++) {- if (i == 0) {- System.out.print(GitUtils.abbreviateSHA(each.getCommit().getHash()));- } else {- System.out.print(StringUtils.repeat(" ", 10));- }-- System.out.print("\t" + (startLine + i));- if (i == 0) {- System.out.print("\t\t" + each.getCommit().getSubject());- }- System.out.print("\n");- }- }- }-}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/git/command/BlameEntry.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/git/command/BlameEntry.javadeleted file mode 100644index 9f00bc395f..0000000000--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/git/command/BlameEntry.java+++ /dev/null@@ -1,109 +0,0 @@-package com.pmease.gitplex.web.git.command;--import java.io.Serializable;--import org.eclipse.jgit.lib.PersonIdent;--import com.google.common.base.Objects;-import com.pmease.commons.git.BriefCommit;--public class BlameEntry implements Serializable, Comparable<BlameEntry> {- private static final long serialVersionUID = 1L;-- private final BriefCommit commit;- private final int sourceLine;- private final int resultLine;- private final int numLines;-- public static class Builder {- private String sha;- private int sourceLine;- private int resultLine;- private int numLines;- private PersonIdent author;- private PersonIdent committer;- private String summary;-- public Builder sha(String sha) {- this.sha = sha;- return this;- }-- public Builder sourceLine(int sourceLine) {- this.sourceLine = sourceLine;- return this;- }-- public Builder resultLine(int resultLine) {- this.resultLine = resultLine;- return this;- }-- public Builder numLines(int numLines) {- this.numLines = numLines;- return this;- }-- public Builder author(PersonIdent author) {- this.author = author;- return this;- }-- public Builder committer(PersonIdent committer) {- this.committer = committer;- return this;- }-- public Builder summary(String summary) {- this.summary = summary;- return this;- }-- public BlameEntry build() {- BriefCommit commit = new BriefCommit(sha, committer, author, summary);- return new BlameEntry(commit, sourceLine, resultLine, numLines);- }- }-- public static Builder builder() {- return new Builder();- }-- BlameEntry(BriefCommit commit, int sourceLine, int resultLine, int numLines) {- this.commit = commit;- this.sourceLine = sourceLine;- this.resultLine = resultLine;- this.numLines = numLines;- }-- public BriefCommit getCommit() {- return commit;- }-- public int getSourceLine() {- return sourceLine;- }-- public int getResultLine() {- return resultLine;- }-- public int getNumLines() {- return numLines;- }-- @Override- public int compareTo(BlameEntry o) {- return resultLine - o.resultLine;- }-- @Override- public String toString() {- return commit.getHash() + " " + sourceLine + " " + resultLine + " " + numLines;- }-- @Override- public int hashCode() {- return Objects.hashCode(commit, sourceLine, resultLine, numLines);- }-}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/git/command/BranchForEachRefCommand.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/git/command/BranchForEachRefCommand.javadeleted file mode 100644index e7725f8975..0000000000--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/git/command/BranchForEachRefCommand.java+++ /dev/null@@ -1,90 +0,0 @@-package com.pmease.gitplex.web.git.command;--import java.io.File;-import java.util.Map;--import org.eclipse.jgit.lib.PersonIdent;--import com.google.common.base.Splitter;-import com.google.common.base.Strings;-import com.google.common.collect.Iterables;-import com.google.common.collect.Maps;-import com.pmease.commons.git.BriefCommit;-import com.pmease.commons.util.execution.Commandline;-import com.pmease.gitplex.web.git.GitUtils;--public class BranchForEachRefCommand extends ForEachRefCommand<Map<String, BriefCommit>, BranchForEachRefCommand> {-- public BranchForEachRefCommand(File repoDir) {- super(repoDir);- }-- private static final String FORMAT =- "%(refname:short)|" + // ref name- "%(objectname)|" + // ref sha-1- "%(committername)|%(committeremail)|%(committerdate:raw)|" + // committer part- "%(authorname)|%(authoremail)|%(authordate:raw)" + // author part- "%09%(contents:subject)"; // \tcommit subject-- @Override- protected String getFormat() {- return FORMAT;- }-- @Override- protected void applyArgs(Commandline cmd) {- super.applyArgs(cmd);-- if (Strings.isNullOrEmpty(getSort())) {- cmd.addArgs("--sort=-committerdate");- }-- if (getPatterns().length == 0) {- cmd.addArgs("refs/heads/");- }- }-- @Override- protected ForEachRefOutputHandler<Map<String, BriefCommit>> getOutputHandler() {- return new BranchOutputHandler();- }-- static class BranchOutputHandler extends ForEachRefOutputHandler<Map<String, BriefCommit>> {- Map<String, BriefCommit> branches = Maps.newLinkedHashMap();-- @Override- public Map<String, BriefCommit> getResult() {- return branches;- }-- @Override- public void consume(String line) {- int pos = line.indexOf('\t');- if (pos <= 0)- return;-- String first = line.substring(0, pos);- String subject = line.substring(pos + 1);- String[] pieces = Iterables.toArray(Splitter.on('|').split(first), String.class);-- int i = 0;- String refname = pieces[i++];- String sha = pieces[i++];-- PersonIdent committer = com.pmease.commons.git.GitUtils.newPersonIdent(pieces[i++],- GitUtils.parseEmail(pieces[i++]),- GitUtils.parseRawDate(pieces[i++]));- PersonIdent author = com.pmease.commons.git.GitUtils.newPersonIdent(pieces[i++],- GitUtils.parseEmail(pieces[i++]),- GitUtils.parseRawDate(pieces[i++]));-- BriefCommit commit = new BriefCommit(sha, committer, author, subject);- branches.put(refname, commit);- }- }-- @Override- protected BranchForEachRefCommand self() {- return this;- }-}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/git/command/ForEachRefCommand.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/git/command/ForEachRefCommand.javadeleted file mode 100644index 924edfec78..0000000000--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/git/command/ForEachRefCommand.java+++ /dev/null@@ -1,114 +0,0 @@-package com.pmease.gitplex.web.git.command;--import java.io.File;-import java.util.Map;--import org.slf4j.Logger;-import org.slf4j.LoggerFactory;--import com.google.common.base.Strings;-import com.google.common.collect.ImmutableList;-import com.google.common.collect.Iterables;-import com.pmease.commons.git.command.GitCommand;-import com.pmease.commons.util.execution.Commandline;-import com.pmease.commons.util.execution.LineConsumer;--public abstract class ForEachRefCommand<T, V extends ForEachRefCommand<T, V>> extends GitCommand<T> {-- private static final Logger logger = LoggerFactory.getLogger(ForEachRefCommand.class);-- private String[] patterns = new String[0];- private int count;- private String sort;-- public ForEachRefCommand(File repoDir) {- super(repoDir);- }-- public ForEachRefCommand(File repoDir, Map<String, String> environments) {- super(repoDir, environments);- }-- public V patterns(String value, String... values) {- if (value == null) {- this.patterns = new String[0];- } else {- this.patterns = Iterables.toArray(ImmutableList.<String>builder()- .add(value)- .add(values)- .build(),- String.class);- }-- return self();- }-- public V count(int count) {- this.count = count;- return self();- }-- public V sort(String sort) {- this.sort = sort;- return self();- }-- abstract protected V self();- abstract protected ForEachRefOutputHandler<T> getOutputHandler();- abstract protected String getFormat();--- @Override- public T call() {- Commandline cmd = cmd();- cmd.addArgs("for-each-ref");-- applyArgs(cmd);-- ForEachRefOutputHandler<T> outputHandler = getOutputHandler();- cmd.execute(outputHandler, getErrorHandler());-- return outputHandler.getResult();- }-- protected LineConsumer getErrorHandler() {- return new LineConsumer() {-- @Override- public void consume(String line) {- logger.error(line);- }-- };- }-- protected void applyArgs(Commandline cmd) {- if (getCount() > 0) {- cmd.addArgs("--count=" + String.valueOf(getCount()));- }-- if (!Strings.isNullOrEmpty(getSort())) {- cmd.addArgs("--sort=" + getSort());- }-- if (!Strings.isNullOrEmpty(getFormat())) {- cmd.addArgs("--format=" + getFormat());- }-- for (String each : getPatterns()) {- cmd.addArgs(each);- }- }-- public String[] getPatterns() {- return patterns;- }-- public int getCount() {- return count;- }-- public String getSort() {- return sort;- }-}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/git/command/ListTagCommand.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/git/command/ListTagCommand.javadeleted file mode 100644index caf82039fa..0000000000--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/git/command/ListTagCommand.java+++ /dev/null@@ -1,169 +0,0 @@-package com.pmease.gitplex.web.git.command;--import java.io.File;-import java.io.IOException;-import java.util.List;-import java.util.Map;-import java.util.regex.Pattern;--import org.slf4j.Logger;-import org.slf4j.LoggerFactory;--import com.google.common.base.Joiner;-import com.google.common.base.Objects;-import com.google.common.base.Splitter;-import com.google.common.collect.Iterables;-import com.google.common.collect.Lists;-import com.google.common.collect.Maps;-import com.google.common.io.LineProcessor;-import com.pmease.commons.git.Commit;-import com.pmease.commons.git.command.GitCommand;-import com.pmease.commons.util.execution.Commandline;-import com.pmease.commons.util.execution.LineConsumer;-import com.pmease.gitplex.web.git.GitUtils;--public class ListTagCommand extends GitCommand<Map<String, Commit>> {-- private static final Logger logger = LoggerFactory.getLogger(ListTagCommand.class);-- public ListTagCommand(File repoDir) {- super(repoDir);- }-- final static String LINE_SEPARATOR = "----g----i----t----o----p----";-- static final String FORMAT = "%d|%H|%aN|%aE|%ad|%cN|%cE|%cd%n%s%n%b%n" + LINE_SEPARATOR;-- @Override- public Map<String, Commit> call() {- Commandline cmd = cmd();- cmd.addArgs("log", "-q", "--no-walk", "--date-order", "--tags", "--decorate=short", "--date=raw");- cmd.addArgs("--format=" + FORMAT + "");-- TagConsumer consumer = new TagConsumer();- cmd.execute(consumer , new LineConsumer() {-- @Override- public void consume(String line) {- logger.error(line);- }-- });-- return consumer.commits;- }-- static enum State {- START, META, SUBJECT, BODY, SEPARATOR;-- public State next() {- int i = ordinal() + 1;- if (i >= State.values().length) {- i = 0;- }- return State.values()[i];- }- }--- public static class TagConsumer extends LineConsumer implements LineProcessor<Map<String, Commit>> {-- private Commit.Builder currentBuilder;- private List<String> messageLines = Lists.newLinkedList();- private State state = State.START;- private List<String> currentNames = Lists.newArrayList();-- final Map<String, Commit> commits = Maps.newLinkedHashMap();-- private void onMeta(String line) {- String[] pieces = Iterables.toArray(Splitter.on("|").split(line), String.class);- int i = 0;- currentNames = parseTagNames(pieces[i++]);- currentBuilder.hash(pieces[i++]);- currentBuilder.author(com.pmease.commons.git.GitUtils.newPersonIdent(- pieces[i++], GitUtils.parseEmail(pieces[i++]), GitUtils.parseRawDate(pieces[i++])));- currentBuilder.committer(com.pmease.commons.git.GitUtils.newPersonIdent(- pieces[i++], GitUtils.parseEmail(pieces[i++]), GitUtils.parseRawDate(pieces[i++])));- }-- private void onFinishBlock() {- // process previous- String body = Joiner.on("\n").join(messageLines);- currentBuilder.body(body);-- Commit commit = currentBuilder.build();- for (String each : currentNames) {- commits.put(each, commit);- }-- currentBuilder = Commit.builder();- messageLines = Lists.newLinkedList();- }-- @Override- public void consume(String line) {- if (state == State.START) {- if (line.trim().startsWith("(tag: ")) {- state = State.META;- currentBuilder = Commit.builder();- } else- return;- }-- if (Objects.equal(line, LINE_SEPARATOR)) {- state = State.SEPARATOR;- }-- switch (state) {- case META:- onMeta(line);- break;-- case SUBJECT:- currentBuilder.subject(line);- break;-- case BODY:- messageLines.add(line);- return; // don't transform state, we may have multiple lines here-- case SEPARATOR:- onFinishBlock();- break;-- default:- return;- }-- state = state.next();- }-- @Override- public boolean processLine(String line) throws IOException {- consume(line);- return true;- }-- @Override- public Map<String, Commit> getResult() {- return commits;- }- }-- static final Pattern pTag = Pattern.compile("\\tag: (.*)");-- static List<String> parseTagNames(final String name) {- String trimed = name.trim();- if (!trimed.startsWith("(tag: "))- throw new IllegalStateException("Tag name field: " + name);-- trimed = trimed.substring(1, trimed.length() - 1);- String[] pieces = Iterables.toArray(Splitter.on(",").trimResults().omitEmptyStrings().split(trimed), String.class);- List<String> result = Lists.newArrayList();- for (String each : pieces) {- result.add(each.substring("tag: ".length()));- }-- return result;- }-}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/git/command/TagForEachRefCommand.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/git/command/TagForEachRefCommand.javadeleted file mode 100644index 95513f7596..0000000000--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/git/command/TagForEachRefCommand.java+++ /dev/null@@ -1,119 +0,0 @@-package com.pmease.gitplex.web.git.command;--import java.io.File;-import java.util.List;-import java.util.Map;--import org.eclipse.jgit.lib.Constants;-import org.eclipse.jgit.lib.PersonIdent;--import com.google.common.base.Joiner;-import com.google.common.base.Objects;-import com.google.common.base.Splitter;-import com.google.common.base.Strings;-import com.google.common.collect.Iterables;-import com.google.common.collect.Lists;-import com.google.common.collect.Maps;-import com.pmease.commons.util.execution.Commandline;-import com.pmease.gitplex.web.git.GitUtils;--public class TagForEachRefCommand extends ForEachRefCommand<Map<String, Tag>, TagForEachRefCommand> {-- public TagForEachRefCommand(File repoDir) {- super(repoDir);- }-- @Override- protected TagForEachRefCommand self() {- return this;- }-- @Override- protected ForEachRefOutputHandler<Map<String, Tag>> getOutputHandler() {- return new TagOutputHandler();- }-- @Override- protected void applyArgs(Commandline cmd) {- super.applyArgs(cmd);-- if (Strings.isNullOrEmpty(getSort())) {- cmd.addArgs("--sort=-creatordate");- }-- if (getPatterns().length == 0) {- cmd.addArgs(Constants.R_TAGS);- }- }-- static final String BLOCK_SEPARATOR = "-----B-----L-----O-----C-----K-----";-- private static final String FORMAT =- "%(refname)|" + // ref name- "%(objectname)|" + // ref sha-1- "%(*objectname)|" + //- "%(creator)|" +- "%0A%(contents:subject)" +- "%0A%(contents:body)" +- "%0A" + BLOCK_SEPARATOR;-- static class TagOutputHandler extends ForEachRefOutputHandler<Map<String, Tag>> {- final Map<String, Tag> tags = Maps.newLinkedHashMap();-- List<String> contents = Lists.newArrayList();-- Tag.Builder builder = Tag.builder();-- @Override- public Map<String, Tag> getResult() {- return tags;- }-- @Override- public void consume(String line) {- if (Objects.equal(line, BLOCK_SEPARATOR)) {- onBlockFinish();- return;- }-- if (line.startsWith(Constants.R_TAGS)) {- onMeta(line);- return;- }-- contents.add(line);- }-- void onMeta(String line) {- String[] pieces = Iterables.toArray(Splitter.on("|").split(line), String.class);- int i = 0;- String refname = pieces[i++].substring(Constants.R_TAGS.length());- builder.name(refname);- String hash1 = pieces[i++];- String hash2 = pieces[i++];- builder.hash(hash1);- builder.commitHash(hash2);-- PersonIdent tagger = GitUtils.parseGitContrib(pieces[i++]);- builder.tagger(tagger);- }-- void onBlockFinish() {- builder.subject(contents.get(0));- builder.body(Joiner.on("\n").join(contents.subList(1, contents.size())));- Tag tag = builder.build();- tags.put(tag.getName(), tag);-- // reset- builder = Tag.builder();- contents = Lists.newArrayList();- }- }--- @Override- protected String getFormat() {- return FORMAT;- }--}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/RepositoryPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/RepositoryPage.javaindex 2c78317a7c..090d96497c 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/RepositoryPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/RepositoryPage.java@@ -50,7 +50,6 @@ import com.pmease.gitplex.web.page.repository.code.branches.RepoBranchesPage;import com.pmease.gitplex.web.page.repository.code.commit.RepoCommitPage;import com.pmease.gitplex.web.page.repository.code.commits.RepoCommitsPage;import com.pmease.gitplex.web.page.repository.code.contributors.ContributorsPage;-import com.pmease.gitplex.web.page.repository.code.tags.TagsPage;import com.pmease.gitplex.web.page.repository.code.tree.RepoTreePage;import com.pmease.gitplex.web.page.repository.pullrequest.ClosedRequestsPage;import com.pmease.gitplex.web.page.repository.pullrequest.NewRequestPage;@@ -205,7 +204,6 @@ public abstract class RepositoryPage extends AccountBasePage {codeTabs.add(new RepositoryTab(Model.of("Files"), "fa fa-file-code", RepoTreePage.class, RepoBlobPage.class));codeTabs.add(new RepositoryTab(Model.of("Commits"), "fa fa-commit", RepoCommitsPage.class, RepoCommitPage.class));codeTabs.add(new RepositoryTab(Model.of("Branches"), "fa fa-branch", RepoBranchesPage.class, BranchComparePage.class));- codeTabs.add(new RepositoryTab(Model.of("Tags"), "fa fa-tags", TagsPage.class));codeTabs.add(new RepositoryTab(Model.of("Contributors"), "fa fa-group-o", ContributorsPage.class));add(new Tabbable("codeTabs", codeTabs));diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/blame/BlobBlamePage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/blame/BlobBlamePage.htmldeleted file mode 100644index 6c601ad7d2..0000000000--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/blame/BlobBlamePage.html+++ /dev/null@@ -1,59 +0,0 @@-<html xmlns:wicket>-<wicket:extend>- <div class="padder">- <div class="blame-head">- <ol class="breadcrumb breadcrumb-paths">- <wicket:container wicket:id="paths"></wicket:container>- </ol>- </div>-- <div wicket:id="content"></div>- </div>-- <wicket:fragment wicket:id="blamefrag">- <div class="blob">- <div class="blob-head clearfix">- <div class="pull-left blob-meta">- <span><i class="icon" wicket:id="typeicon"></i> <span wicket:id="mode"></span></span>- <wicket:enclosure child="loc">- <span><wicket:container wicket:id="loc"></wicket:container> lines (<wicket:container wicket:id="sloc"></wicket:container> sloc)</span>- </wicket:enclosure>- <span wicket:id="size"></span>- </div>- <div class="pull-right blob-actions btn-toolbar">- <div class="btn-group">- <a class="btn btn-sm btn-default">Raw</a>- <a wicket:id="normallink" class="btn btn-sm btn-default">Normal View</a>- <a wicket:id="historylink" class="btn btn-sm btn-default">History</a>- </div>- </div>- </div>- <div class="blob-body" wicket:id="body"></div>- </div>- </wicket:fragment>-- <wicket:fragment wicket:id="infofrag">- <div class="alert alert-warning">- This file doesn't support blame view- </div>- </wicket:fragment>-- <wicket:fragment wicket:id="blameColumnFrag">- <td class="blame-msg">- <div class="blob-blames">- <div wicket:id="rows" class="blame-row" data-toggle="tooltip">- <div class="section-first">- <a wicket:id="shalink"><span wicket:id="sha"></span></a>- <a wicket:id="blamelink">»</a>- - <i wicket:id="date"></i>- - <wicket:container wicket:id="author"></wicket:container>- </div>- <div wicket:id="empties"> </div>- </div>- </div>- </td>- </wicket:fragment>-</wicket:extend>-</html>\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/blame/BlobBlamePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/blame/BlobBlamePage.javadeleted file mode 100644index beabdd4cc3..0000000000--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/blame/BlobBlamePage.java+++ /dev/null@@ -1,251 +0,0 @@-package com.pmease.gitplex.web.page.repository.code.blame;--import java.util.List;--import org.apache.commons.lang3.StringUtils;-import org.apache.wicket.AttributeModifier;-import org.apache.wicket.Component;-import org.apache.wicket.RestartResponseException;-import org.apache.wicket.markup.head.IHeaderResponse;-import org.apache.wicket.markup.head.OnDomReadyHeaderItem;-import org.apache.wicket.markup.html.WebMarkupContainer;-import org.apache.wicket.markup.html.basic.Label;-import org.apache.wicket.markup.html.link.BookmarkablePageLink;-import org.apache.wicket.markup.html.list.Loop;-import org.apache.wicket.markup.html.list.LoopItem;-import org.apache.wicket.markup.html.panel.Fragment;-import org.apache.wicket.markup.repeater.RepeatingView;-import org.apache.wicket.model.AbstractReadOnlyModel;-import org.apache.wicket.model.IModel;-import org.apache.wicket.model.LoadableDetachableModel;-import org.apache.wicket.model.Model;-import org.apache.wicket.request.mapper.parameter.PageParameters;-import org.eclipse.jgit.lib.FileMode;--import com.pmease.commons.hibernate.dao.Dao;-import com.pmease.gitplex.core.GitPlex;-import com.pmease.gitplex.core.model.Repository;-import com.pmease.gitplex.web.common.datatype.DataTypes;-import com.pmease.gitplex.web.common.quantity.Data;-import com.pmease.gitplex.web.common.wicket.bootstrap.Icon;-import com.pmease.gitplex.web.component.user.AvatarMode;-import com.pmease.gitplex.web.component.user.PersonLink;-import com.pmease.gitplex.web.git.GitUtils;-import com.pmease.gitplex.web.git.command.BlameCommand;-import com.pmease.gitplex.web.git.command.BlameEntry;-import com.pmease.gitplex.web.page.repository.NoCommitsPage;-import com.pmease.gitplex.web.page.repository.RepositoryPage;-import com.pmease.gitplex.web.page.repository.code.blob.RepoBlobPage;-import com.pmease.gitplex.web.page.repository.code.blob.renderer.TextBlobPanel;-import com.pmease.gitplex.web.page.repository.code.commit.RepoCommitPage;-import com.pmease.gitplex.web.page.repository.code.commits.RepoCommitsPage;-import com.pmease.gitplex.web.page.repository.code.component.PathsBreadcrumb;-import com.pmease.gitplex.web.service.FileBlob;--@SuppressWarnings("serial")-public class BlobBlamePage extends RepositoryPage {-- private final IModel<FileBlob> blobModel;-- private final IModel<List<BlameEntry>> blamesModel;-- public BlobBlamePage(PageParameters params) {- super(params);-- if (!getRepository().git().hasCommits())- throw new RestartResponseException(NoCommitsPage.class, paramsOf(getRepository()));-- this.blobModel = new LoadableDetachableModel<FileBlob>() {-- @Override- protected FileBlob load() {- return FileBlob.of(getRepository(), getRepository().defaultBranchIfNull(getCurrentRevision()), getCurrentPath());- }-- };-- this.blamesModel = new LoadableDetachableModel<List<BlameEntry>>() {-- @Override- protected List<BlameEntry> load() {- BlameCommand cmd = new BlameCommand(getRepository().git().repoDir());- cmd.fileName(getCurrentPath()).objectId(getRepository().defaultBranchIfNull(getCurrentRevision()));-- return cmd.call();- }-- };- }-- @Override- protected String getPageTitle() {- return getCurrentPath() + " at " + getRepository().defaultBranchIfNull(getCurrentRevision()) + " " + getRepository().getFullName();- }-- @Override- protected void onInitialize() {- super.onInitialize();-- add(new PathsBreadcrumb("paths", repoModel, currentRevision, currentPath));-- FileBlob blob = getBlob();- if (blob.isText()) {- add(createBlameView("content"));- } else {- add(createInfoView("content"));- }- }-- private Component createBlameView(String id) {- Fragment frag = new Fragment(id, "blamefrag", this);-- frag.add(new Label("mode", new AbstractReadOnlyModel<String>() {-- @Override- public String getObject() {- FileMode mode = getBlob().getMode();- if (mode == FileMode.SYMLINK) {- return "symbolic link";- } else if (mode == FileMode.EXECUTABLE_FILE) {- return "executable file";- } else {- return "file";- }- }-- }));-- frag.add(new Icon("typeicon", new AbstractReadOnlyModel<String>() {-- @Override- public String getObject() {- return "fa-file-txt";- }- }));-- frag.add(new Label("size", new AbstractReadOnlyModel<String>() {-- @Override- public String getObject() {- return Data.formatBytes(getBlob().getSize(), Data.KB);- }-- }));-- frag.add(new Label("loc", new AbstractReadOnlyModel<Integer>() {-- @Override- public Integer getObject() {- return getBlob().getLines().size();- }-- }).setVisibilityAllowed(getBlob().isText()));-- frag.add(new Label("sloc", new AbstractReadOnlyModel<Integer>() {-- @Override- public Integer getObject() {- List<String> lines = getBlob().getLines();- int sloc = 0;- for (String each : lines) {- if (!StringUtils.isBlank(each)) {- sloc++;- }- }-- return sloc;- }-- }));-- FileBlob blob = getBlob();- Repository repository = GitPlex.getInstance(Dao.class).load(Repository.class, blob.getRepositoryId());- frag.add(new BookmarkablePageLink<Void>("historylink", RepoCommitsPage.class,- RepoCommitsPage.paramsOf(- repository,- blob.getRevision(),- blob.getFilePath(),- 0)));-- frag.add(new BookmarkablePageLink<Void>("normallink",- RepoBlobPage.class,- RepoBlobPage.paramsOf(repository, blob.getRevision(), blob.getFilePath())));-- frag.add(new TextBlobPanel("body", blobModel) {-- @Override- protected Component createPrependColumn(String id) {- Fragment frag = new Fragment(id, "blameColumnFrag", BlobBlamePage.this);-- List<BlameEntry> entries = blamesModel.getObject();-- RepeatingView view = new RepeatingView("rows");- frag.add(view);- for (BlameEntry each : entries) {- WebMarkupContainer container = new WebMarkupContainer(view.newChildId());- view.add(container);- container.add(AttributeModifier.replace("title", each.getCommit().getSubject()));- String hash = each.getCommit().getHash();- BookmarkablePageLink<Void> link = new BookmarkablePageLink<Void>(- "shalink",- RepoCommitPage.class,- RepoCommitPage.paramsOf(getRepository(), hash, null));-- link.add(new Label("sha", GitUtils.abbreviateSHA(each.getCommit().getHash(), 8)));- container.add(link);- container.add(new PersonLink("author", Model.of(each.getCommit().getAuthor()), AvatarMode.NAME));-- container.add(new Label("date",- DataTypes.DATE.asString(each.getCommit().getAuthor().getWhen(), "yyyy-MM-dd")));- BookmarkablePageLink<Void> blameLink = new BookmarkablePageLink<Void>(- "blamelink",- BlobBlamePage.class,- BlobBlamePage.paramsOf(getRepository(), hash, getCurrentPath()));- container.add(blameLink);- Loop loop = new Loop("empties", each.getNumLines() - 1) {-- @Override- protected void populateItem(LoopItem item) {-- }- };- container.add(loop);- }-- frag.setRenderBodyOnly(true);- return frag;- }- });-- return frag;- }-- private Component createInfoView(String id) {- Fragment frag = new Fragment(id, "infofrag", this);- return frag;- }-- private FileBlob getBlob() {- return blobModel.getObject();- }-- @Override- public void renderHead(IHeaderResponse response) {- super.renderHead(response);-- response.render(OnDomReadyHeaderItem.forScript("$('.blame-row').tooltip({placement: 'top'});"));- }-- @Override- public void onDetach() {- if (blobModel != null) {- blobModel.detach();- }-- if (blamesModel != null) {- blamesModel.detach();- }-- super.onDetach();- }-}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/blob/RepoBlobPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/blob/RepoBlobPage.javaindex 6397527004..2627729263 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/blob/RepoBlobPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/blob/RepoBlobPage.java@@ -89,7 +89,7 @@ public class RepoBlobPage extends RepositoryPage {@Overridepublic String getObject() {- return getLastCommit().getSubject();+ return getLastCommit().getMessageSummary();}}));@@ -104,7 +104,7 @@ public class RepoBlobPage extends RepositoryPage {protected void onConfigure() {super.onConfigure();- if (Objects.equal(getLastCommit().getSubject(), getLastCommit().getMessage())) {+ if (Objects.equal(getLastCommit().getMessageSummary(), getLastCommit().getMessage())) {this.setVisibilityAllowed(false);}}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/blob/RepoBlobPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/blob/RepoBlobPanel.htmlindex b52186442e..7d2cc66f4e 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/blob/RepoBlobPanel.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/blob/RepoBlobPanel.html@@ -12,7 +12,6 @@<div class="pull-right blob-actions btn-toolbar"><div class="btn-group"><a wicket:id="rawlink" class="btn btn-sm btn-default">Raw</a>- <a wicket:id="blamelink" class="btn btn-sm btn-default">Blame</a><a wicket:id="historylink" class="btn btn-sm btn-default">History</a></div>diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/blob/RepoBlobPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/blob/RepoBlobPanel.javaindex 15ebe7fe83..f86c14986f 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/blob/RepoBlobPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/blob/RepoBlobPanel.java@@ -16,7 +16,6 @@ import com.pmease.gitplex.core.GitPlex;import com.pmease.gitplex.core.model.Repository;import com.pmease.gitplex.web.common.quantity.Data;import com.pmease.gitplex.web.common.wicket.bootstrap.Icon;-import com.pmease.gitplex.web.page.repository.code.blame.BlobBlamePage;import com.pmease.gitplex.web.page.repository.code.blob.renderer.BlobRenderer;import com.pmease.gitplex.web.page.repository.code.blob.renderer.BlobRendererFactory;import com.pmease.gitplex.web.page.repository.code.blob.renderer.RawBlobResourceReference;@@ -104,10 +103,6 @@ public class RepoBlobPanel extends Panel {blob.getFilePath(),0)));- add(new BookmarkablePageLink<Void>("blamelink",- BlobBlamePage.class,- BlobBlamePage.paramsOf(repository, blob.getRevision(), blob.getFilePath())).setVisibilityAllowed(blob.isText()));-add(new ResourceLink<Void>("rawlink", new RawBlobResourceReference(),RawBlobResourceReference.paramsOf(blob)));diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/branches/RepoBranchesPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/branches/RepoBranchesPage.javaindex 680da2f3a7..11621f6ba7 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/branches/RepoBranchesPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/branches/RepoBranchesPage.java@@ -64,7 +64,6 @@ import com.pmease.gitplex.web.component.user.AvatarMode;import com.pmease.gitplex.web.component.user.PersonLink;import com.pmease.gitplex.web.git.command.AheadBehind;import com.pmease.gitplex.web.git.command.AheadBehindCommand;-import com.pmease.gitplex.web.git.command.BranchForEachRefCommand;import com.pmease.gitplex.web.page.repository.NoCommitsPage;import com.pmease.gitplex.web.page.repository.RepositoryPage;import com.pmease.gitplex.web.page.repository.code.tree.RepoTreePage;@@ -89,8 +88,7 @@ public class RepoBranchesPage extends RepositoryPage {@Overrideprotected Map<String, BriefCommit> load() {- BranchForEachRefCommand cmd = new BranchForEachRefCommand(getRepository().git().repoDir());- return cmd.call();+ return getRepository().git().listHeadCommits();}};diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/commit/RepoCommitPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/commit/RepoCommitPage.javaindex bb5a477b1a..38ca65691c 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/commit/RepoCommitPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/commit/RepoCommitPage.java@@ -252,10 +252,10 @@ public class RepoCommitPage extends RepositoryPage implements CommitCommentsAwarprotected String getPageTitle() {String revision = getRepository().defaultBranchIfNull(getCurrentRevision());if (GitUtils.isHash(revision)) {- return getCommit().getSubject() + " - " + GitUtils.abbreviateSHA(revision, 8)+ return getCommit().getMessageSummary() + " - " + GitUtils.abbreviateSHA(revision, 8)+ " - " + getRepository().getFullName();} else {- return getCommit().getSubject() + " - " + revision+ return getCommit().getMessageSummary() + " - " + revision+ " - " + getRepository().getFullName();}}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/commits/RepoCommitsPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/commits/RepoCommitsPanel.javaindex 2e3b502002..c3bd99ff3f 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/commits/RepoCommitsPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/commits/RepoCommitsPanel.java@@ -6,7 +6,6 @@ import java.util.Date;import java.util.List;import java.util.Map;-import com.pmease.gitplex.core.GitPlex;import org.apache.commons.lang3.time.DateUtils;import org.apache.wicket.markup.head.IHeaderResponse;import org.apache.wicket.markup.head.OnDomReadyHeaderItem;@@ -25,6 +24,7 @@ import com.google.common.collect.LinkedListMultimap;import com.google.common.collect.Lists;import com.google.common.collect.Multimap;import com.pmease.commons.git.Commit;+import com.pmease.gitplex.core.GitPlex;import com.pmease.gitplex.core.manager.OldCommitCommentManager;import com.pmease.gitplex.core.model.Repository;import com.pmease.gitplex.web.common.datatype.DataTypes;diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/component/RevisionSelector.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/component/RevisionSelector.javaindex e3c1b311bf..92a0314003 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/component/RevisionSelector.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/component/RevisionSelector.java@@ -64,7 +64,7 @@ public class RevisionSelector extends Panel {protected Map<RefType, List<String>> load() {Git git = RevisionSelector.this.repoModel.getObject().git();Map<RefType, List<String>> map = Maps.newHashMapWithExpectedSize(RefType.values().length);- map.put(RefType.BRANCH, Lists.newArrayList(git.listBranches().keySet()));+ map.put(RefType.BRANCH, Lists.newArrayList(git.listBranches()));List<String> tags = Lists.newArrayList(git.listTags());Collections.reverse(tags);map.put(RefType.TAG, tags);diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/tags/TagsPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/tags/TagsPage.htmldeleted file mode 100644index 0b59606bd7..0000000000--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/tags/TagsPage.html+++ /dev/null@@ -1,42 +0,0 @@-<html xmlns:wicket>-<wicket:extend>- <div class="padder">- <div class="page-heading">- <h2 class="section-title">Tags</h2>- </div>-- <wicket:container wicket:id="content"></wicket:container>- </div>-- <wicket:fragment wicket:id="norecord">- <div class="alert alert-warning">- <h3>There aren't any tags yet</h3>- <p></p>- </div>- </wicket:fragment>-- <wicket:fragment wicket:id="tagsfrag">- <table class="table table-tags">- <tr wicket:id="tags">- <td class="date">- <p><span wicket:id="creator"></span></p>- <span wicket:id="date"></span>- </td>- <td class="meta">- <h3><span wicket:id="tagname"></span></h3>- <pre wicket:id="message"></pre>- <ul class="list-inline">- <li><a wicket:id="commitlink"><i class="fa fa-commit"></i> <span class="sha" wicket:id="hash"></span></a></li>- <li><a wicket:id="ziplink"><i class="fa fa-file-zip"></i> zip</a></li>- <li><a wicket:id="targzlink"><i class="fa fa-file-zip"></i> tar.gz</a></li>- </ul>- </td>- </tr>- </table>- <div class="btn-group" wicket:id="navigator">- <a class="btn btn-default" wicket:id="previouslink"><i class="fa fa-arrow-slim-left"></i> Previous</a>- <a class="btn btn-default" wicket:id="nextlink">Next <i class="fa fa-arrow-slim-right"></i></a>- </div>- </wicket:fragment>-</wicket:extend>-</html>\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/tags/TagsPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/tags/TagsPage.javadeleted file mode 100644index 87dd9a1164..0000000000--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/tags/TagsPage.java+++ /dev/null@@ -1,230 +0,0 @@-package com.pmease.gitplex.web.page.repository.code.tags;--import java.util.List;-import java.util.Map;--import org.apache.wicket.RestartResponseException;-import org.apache.wicket.markup.html.WebMarkupContainer;-import org.apache.wicket.markup.html.basic.Label;-import org.apache.wicket.markup.html.link.AbstractLink;-import org.apache.wicket.markup.html.link.BookmarkablePageLink;-import org.apache.wicket.markup.html.link.ResourceLink;-import org.apache.wicket.markup.html.list.ListItem;-import org.apache.wicket.markup.html.list.ListView;-import org.apache.wicket.markup.html.panel.Fragment;-import org.apache.wicket.model.AbstractReadOnlyModel;-import org.apache.wicket.model.IModel;-import org.apache.wicket.model.LoadableDetachableModel;-import org.apache.wicket.model.Model;-import org.apache.wicket.request.mapper.parameter.PageParameters;--import com.google.common.base.Objects;-import com.google.common.base.Strings;-import com.google.common.collect.ImmutableList;-import com.google.common.collect.Iterables;-import com.google.common.collect.Lists;-import com.pmease.gitplex.core.model.Repository;-import com.pmease.gitplex.web.component.label.AgeLabel;-import com.pmease.gitplex.web.component.user.AvatarMode;-import com.pmease.gitplex.web.component.user.PersonLink;-import com.pmease.gitplex.web.git.GitUtils;-import com.pmease.gitplex.web.git.command.ArchiveCommand.Format;-import com.pmease.gitplex.web.git.command.Tag;-import com.pmease.gitplex.web.git.command.TagForEachRefCommand;-import com.pmease.gitplex.web.page.repository.NoCommitsPage;-import com.pmease.gitplex.web.page.repository.RepositoryPage;-import com.pmease.gitplex.web.page.repository.code.commit.RepoCommitPage;--import de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipConfig;-import de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipConfig.Placement;--@SuppressWarnings("serial")-public class TagsPage extends RepositoryPage {-- private final IModel<Map<String, Tag>> tagsModel;-- private String before;-- public static PageParameters paramsOf(Repository repository, String before) {- PageParameters parameters = paramsOf(repository);- if (!Strings.isNullOrEmpty(before)) {- parameters.add("before", before);- }-- return parameters;- }-- public TagsPage(PageParameters params) {- super(params);-- if (!getRepository().git().hasCommits())- throw new RestartResponseException(NoCommitsPage.class, paramsOf(getRepository()));-- tagsModel = new LoadableDetachableModel<Map<String, Tag>>() {-- @Override- protected Map<String, Tag> load() {- Map<String, Tag> map = new TagForEachRefCommand(getRepository().git().repoDir()).call();- return map;- }-- };-- before = params.get("before").toString();- }-- @Override- protected void onInitialize() {- super.onInitialize();-- Map<String, Tag> tags = tagsModel.getObject();- if (tags.isEmpty()) {- Fragment frag = new Fragment("content", "norecord", this);- add(frag);- } else {- Fragment frag = new Fragment("content", "tagsfrag", this);- add(frag);-- IModel<List<String>> tagNames = new AbstractReadOnlyModel<List<String>>() {-- @Override- public List<String> getObject() {- return getCurrentTagNames();- }-- };-- frag.add(new ListView<String>("tags", tagNames) {-- @Override- protected void populateItem(ListItem<String> item) {- String tagName = item.getModelObject();- Tag tag = getTagCommit(tagName);-- if (tag.getTagger() == null) {- item.add(new WebMarkupContainer("creator").setVisibilityAllowed(false));- item.add(new WebMarkupContainer("date").setVisibilityAllowed(false));- } else {- TooltipConfig tooltipConfig = new TooltipConfig().withPlacement(Placement.right);- item.add(new PersonLink("creator", Model.of(tag.getTagger()), AvatarMode.AVATAR)- .withTooltipConfig(tooltipConfig));- item.add(new AgeLabel("date", Model.of(tag.getTagger().getWhen())));- }-- item.add(new Label("tagname", tagName));- item.add(new Label("message", tag.getMessage()));- AbstractLink commitLink = new BookmarkablePageLink<Void>("commitlink",- RepoCommitPage.class,- RepoCommitPage.paramsOf(getRepository(), tag.getSha(), null));-- item.add(commitLink);- commitLink.add(new Label("hash", GitUtils.abbreviateSHA(tag.getSha())));-- item.add(new ResourceLink<Void>("ziplink",- new GitArchiveResourceReference(),- GitArchiveResourceReference.newParams(getRepository(), tagName, Format.ZIP)));- item.add(new ResourceLink<Void>("targzlink",- new GitArchiveResourceReference(),- GitArchiveResourceReference.newParams(getRepository(), tagName, Format.TAR_GZ)));- }-- });-- String last = getLastInAll();-- WebMarkupContainer navigator = new WebMarkupContainer("navigator");- navigator.setVisibilityAllowed(- !Objects.equal(getCurrentTagNames(), getAllTagNames()));- frag.add(navigator);-- String previous = getPreviousPos();- String next = getNextPos();- navigator.add(new BookmarkablePageLink<Void>("previouslink",- TagsPage.class,- paramsOf(getRepository(), previous)).setEnabled(previous != null));- navigator.add(new BookmarkablePageLink<Void>("nextlink", TagsPage.class,- paramsOf(getRepository(), next)).setEnabled(!Objects.equal(last, next)));- }- }-- private int getPageNo() {- List<String> allTags = getAllTagNames();- int beforePos = findPosition(allTags, before);- if (beforePos <= 0) {- return 0;- }-- return (beforePos + 1) / MAX_ROWS;- }-- private List<String> getTagNamesInPage(int pageNo) {- List<String> allTags = getAllTagNames();- int start = pageNo * MAX_ROWS;- int end = Math.min((pageNo + 1) * MAX_ROWS, allTags.size());-- return ImmutableList.copyOf(allTags.subList(start, end));- }-- private List<String> getCurrentTagNames() {- int pageNo = getPageNo();- return getTagNamesInPage(pageNo);- }-- private String getNextPos() {- List<String> current = getCurrentTagNames();- return Iterables.getLast(current, null);- }-- private String getPreviousPos() {- int previousPage = getPageNo() - 1;- if (previousPage < 0) {- return null;- } else if (previousPage == 0) {- return "";- }-- List<String> names = getTagNamesInPage(previousPage);- return Iterables.getFirst(names, null);- }-- private List<String> getAllTagNames() {- return Lists.newArrayList(tagsModel.getObject().keySet());- }-- private String getLastInAll() {- Map<String, Tag> tags = tagsModel.getObject();- return Iterables.getLast(tags.keySet(), null);- }-- static final int MAX_ROWS = 50;-- static int findPosition(List<String> list, String str) {- if (Strings.isNullOrEmpty(str))- return -1;-- for (int i = 0; i < list.size(); i++) {- if (Objects.equal(str, list.get(i)))- return i;- }-- return -1;- }-- Tag getTagCommit(String name) {- return tagsModel.getObject().get(name);- }-- @Override- protected String getPageTitle() {- return getRepository() + " - tags";- }-- @Override- public void onDetach() {- super.onDetach();-- if (tagsModel != null) {- tagsModel.detach();- }- }-}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/NewRequestPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/NewRequestPage.javaindex db2bde4b37..c7f18ffdf8 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/NewRequestPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/NewRequestPage.java@@ -427,7 +427,7 @@ public class NewRequestPage extends RepositoryPage {List<Commit> commits = commitsModel.getObject();Preconditions.checkState(!commits.isEmpty());if (commits.size() == 1)- pullRequest.setTitle(commits.get(0).getSubject());+ pullRequest.setTitle(commits.get(0).getMessageSummary());elsepullRequest.setTitle(pullRequest.getSource().getName());}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestComparePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestComparePage.javaindex 03149efd57..8d6228c6b8 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestComparePage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestComparePage.java@@ -96,7 +96,7 @@ public class RequestComparePage extends RequestDetailPage {PullRequest request = getPullRequest();String name = "Base of Pull Request";- CommitDescription description = new CommitDescription(name, request.getBaseCommit().getSubject());+ CommitDescription description = new CommitDescription(name, request.getBaseCommit().getMessageSummary());choices.put(request.getBaseCommitHash(), description);for (int i=0; i<request.getSortedUpdates().size(); i++) {@@ -104,14 +104,14 @@ public class RequestComparePage extends RequestDetailPage {int updateNo = i+1;name = "Head of Update #" + updateNo;Commit commit = update.getHeadCommit();- description = new CommitDescription(name, commit.getSubject());+ description = new CommitDescription(name, commit.getMessageSummary());choices.put(commit.getHash(), description);}String targetHead = request.getTarget().getHeadCommitHash();if (!choices.containsKey(targetHead)) {description = new CommitDescription(TARGET_BRANCH_HEAD,- getRepository().getCommit(targetHead).getSubject());+ getRepository().getCommit(targetHead).getMessageSummary());choices.put(targetHead, description);}@@ -120,7 +120,7 @@ public class RequestComparePage extends RequestDetailPage {if (preview != null && preview.getIntegrated() != null&& !getRepository().getChanges(preview.getRequestHead(), preview.getIntegrated()).isEmpty()) {Commit commit = getRepository().getCommit(preview.getIntegrated());- choices.put(commit.getHash(), new CommitDescription(INTEGRATION_PREVIEW, commit.getSubject()));+ choices.put(commit.getHash(), new CommitDescription(INTEGRATION_PREVIEW, commit.getMessageSummary()));}}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestUpdatesPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestUpdatesPage.javaindex aa438d4122..cecffb0e81 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestUpdatesPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestUpdatesPage.java@@ -26,9 +26,9 @@ import org.apache.wicket.request.mapper.parameter.PageParameters;import com.pmease.commons.git.Commit;import com.pmease.gitplex.core.model.PullRequestUpdate;-import com.pmease.gitplex.core.model.Repository;import com.pmease.gitplex.core.model.PullRequestVerification;import com.pmease.gitplex.core.model.PullRequestVote;+import com.pmease.gitplex.core.model.Repository;import com.pmease.gitplex.web.component.comment.event.PullRequestChanged;import com.pmease.gitplex.web.component.commit.CommitHashLink;import com.pmease.gitplex.web.component.commit.CommitMessagePanel;diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/UpdateActivityPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/UpdateActivityPanel.javaindex 513f96746d..ec9a261b92 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/UpdateActivityPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/UpdateActivityPanel.java@@ -19,8 +19,8 @@ import org.apache.wicket.model.Model;import com.pmease.commons.git.Commit;import com.pmease.gitplex.core.model.PullRequest;import com.pmease.gitplex.core.model.PullRequestUpdate;-import com.pmease.gitplex.core.model.Repository;import com.pmease.gitplex.core.model.PullRequestVerification;+import com.pmease.gitplex.core.model.Repository;import com.pmease.gitplex.web.component.commit.CommitHashLink;import com.pmease.gitplex.web.component.commit.CommitMessagePanel;import com.pmease.gitplex.web.component.user.AvatarMode;