]> source.dussan.org Git - gitblit.git/commitdiff
Set author as tooltip of "last change" on repositories page (issue-238)
authorJames Moger <james.moger@gitblit.com>
Wed, 3 Jul 2013 15:11:48 +0000 (11:11 -0400)
committerJames Moger <james.moger@gitblit.com>
Wed, 3 Jul 2013 15:11:48 +0000 (11:11 -0400)
releases.moxie
src/main/java/com/gitblit/GitBlit.java
src/main/java/com/gitblit/models/RepositoryModel.java
src/main/java/com/gitblit/utils/JGitUtils.java
src/main/java/com/gitblit/wicket/pages/OverviewPage.java
src/main/java/com/gitblit/wicket/pages/SummaryPage.java
src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.java
src/test/java/com/gitblit/tests/JGitUtilsTest.java

index 78bc340c69502d314ef94317d0956a5df3f97428..8cff77117eb77981204aa8c36bbc18ec858010d6 100644 (file)
@@ -60,6 +60,7 @@ r17: {
         - Support header color customizations (issue 209)\r
         - Support username substitution in web.otherUrls (issue 213)\r
         - Option to force client-side basic authentication instead of form-based authentication if web.authenticateViewPages=true (issue 222)\r
+        - Set author as tooltip of last change column in the repositories panel (issue-238)\r
         - Setting to automatically create an user account based on an authenticated user principal from the servlet container (issue-246)\r
         - Added WindowsUserService to authenticate users against Windows accounts (issue-250)\r
         - Global and per-repository setting to exclude authors from metrics (issue-251)\r
index ca21717c07263aac4c3d3962ddb0bb85f9dd91d5..6f2f70cca5b4cb47130bd92d5076662a0f52ec21 100644 (file)
@@ -121,6 +121,7 @@ import com.gitblit.utils.DeepCopier;
 import com.gitblit.utils.FederationUtils;
 import com.gitblit.utils.HttpUtils;
 import com.gitblit.utils.JGitUtils;
+import com.gitblit.utils.JGitUtils.LastChange;
 import com.gitblit.utils.JsonUtils;
 import com.gitblit.utils.MetricUtils;
 import com.gitblit.utils.ObjectCache;
@@ -1669,7 +1670,9 @@ public class GitBlit implements ServletContextListener {
                                model.hasCommits = JGitUtils.hasCommits(r);
                        }
 
-                       model.lastChange = JGitUtils.getLastChange(r);
+                       LastChange lc = JGitUtils.getLastChange(r);
+                       model.lastChange = lc.when;
+                       model.lastChangeAuthor = lc.who;
                        if (!model.skipSizeCalculation) {
                                ByteFormat byteFormat = new ByteFormat();
                                model.size = byteFormat.format(calculateSize(model));
@@ -1973,7 +1976,9 @@ public class GitBlit implements ServletContextListener {
                        model.name = repositoryName;
                }
                model.hasCommits = JGitUtils.hasCommits(r);
-               model.lastChange = JGitUtils.getLastChange(r);
+               LastChange lc = JGitUtils.getLastChange(r);
+               model.lastChange = lc.when;
+               model.lastChangeAuthor = lc.who;
                model.projectPath = StringUtils.getFirstPathElement(repositoryName);
                
                StoredConfig config = r.getConfig();
index 5eb51b4b972cf219747457776c5ac5221bbe1a59..2996265857a135fafeb4b8b71109f797a4d0ca32 100644 (file)
@@ -46,6 +46,7 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
        public String description;\r
        public List<String> owners;\r
        public Date lastChange;\r
+       public String lastChangeAuthor;\r
        public boolean hasCommits;\r
        public boolean showRemoteBranches;\r
        public boolean useTickets;\r
index 9dabebe69800246275f201de335de32fcf2570cb..8676d748c6ff14df5614a1117b50c7d518a39835 100644 (file)
@@ -439,39 +439,56 @@ public class JGitUtils {
                }\r
                return false;\r
        }\r
+       \r
+       /**\r
+        * Encapsulates the result of cloning or pulling from a repository.\r
+        */\r
+       public static class LastChange {\r
+               public Date when;\r
+               public String who;\r
+               \r
+               LastChange() {\r
+                       when = new Date(0);                     \r
+               }\r
+               \r
+               LastChange(long lastModified) {\r
+                       this.when = new Date(lastModified);\r
+               }\r
+       }\r
 \r
        /**\r
-        * Returns the date of the most recent commit on a branch. If the repository\r
-        * does not exist Date(0) is returned. If it does exist but is empty, the\r
-        * last modified date of the repository folder is returned.\r
+        * Returns the date and author of the most recent commit on a branch. If the\r
+        * repository does not exist Date(0) is returned. If it does exist but is\r
+        * empty, the last modified date of the repository folder is returned.\r
         * \r
         * @param repository\r
-        * @return\r
+        * @return a LastChange object\r
         */\r
-       public static Date getLastChange(Repository repository) {\r
+       public static LastChange getLastChange(Repository repository) {\r
                if (!hasCommits(repository)) {\r
                        // null repository\r
                        if (repository == null) {\r
-                               return new Date(0);\r
+                               return new LastChange();\r
                        }\r
                        // fresh repository\r
-                       return new Date(repository.getDirectory().lastModified());\r
+                       return new LastChange(repository.getDirectory().lastModified());\r
                }\r
 \r
                List<RefModel> branchModels = getLocalBranches(repository, true, -1);\r
                if (branchModels.size() > 0) {\r
                        // find most recent branch update\r
-                       Date lastChange = new Date(0);\r
+                       LastChange lastChange = new LastChange();                       \r
                        for (RefModel branchModel : branchModels) {\r
-                               if (branchModel.getDate().after(lastChange)) {\r
-                                       lastChange = branchModel.getDate();\r
+                               if (branchModel.getDate().after(lastChange.when)) {\r
+                                       lastChange.when = branchModel.getDate();\r
+                                       lastChange.who = branchModel.getAuthorIdent().getName();\r
                                }\r
                        }\r
                        return lastChange;\r
                }\r
                \r
                // default to the repository folder modification date\r
-               return new Date(repository.getDirectory().lastModified());\r
+               return new LastChange(repository.getDirectory().lastModified());\r
        }\r
 \r
        /**\r
index 88487670bd0ee78599dcccb1e62d161a5ffa7e8a..ff6326d40a39054ba71b4971846eb9a462aae247 100644 (file)
@@ -98,7 +98,7 @@ public class OverviewPage extends RepositoryPage {
                add(ownersView);\r
                \r
                add(WicketUtils.createTimestampLabel("repositoryLastChange",\r
-                               JGitUtils.getLastChange(r), getTimeZone(), getTimeUtils()));\r
+                               JGitUtils.getLastChange(r).when, getTimeZone(), getTimeUtils()));\r
                add(new Label("repositorySize", model.size));\r
                \r
                if (metricsTotal == null) {\r
index 1afa967a1140b8af3e0a00d5226da9cfb64d77d0..c231b2ba97973ae6d213f587fda23dbb4ffa681d 100644 (file)
@@ -116,7 +116,7 @@ public class SummaryPage extends RepositoryPage {
                add(ownersView);\r
                \r
                add(WicketUtils.createTimestampLabel("repositoryLastChange",\r
-                               JGitUtils.getLastChange(r), getTimeZone(), getTimeUtils()));\r
+                               JGitUtils.getLastChange(r).when, getTimeZone(), getTimeUtils()));\r
                add(new Label("repositorySize", getRepositoryModel().size));\r
                if (metricsTotal == null) {\r
                        add(new Label("branchStats", ""));\r
index e0f93934d459c499d9b60396f9ad6e96c4a48e84..1b7d0e0e46f851596e5a63cce85323ff53f37137 100644 (file)
@@ -322,6 +322,9 @@ public class RepositoriesPanel extends BasePanel {
                                Label lastChangeLabel = new Label("repositoryLastChange", lastChange);\r
                                row.add(lastChangeLabel);\r
                                WicketUtils.setCssClass(lastChangeLabel, getTimeUtils().timeAgoCss(entry.lastChange));\r
+                               if (!StringUtils.isEmpty(entry.lastChangeAuthor)) {\r
+                                       WicketUtils.setHtmlTooltip(lastChangeLabel, getString("gb.author") + ": " + entry.lastChangeAuthor);\r
+                               }\r
 \r
                                boolean showOwner = user != null && entry.isOwner(user.username);\r
                                boolean myPersonalRepository = showOwner && entry.isUsersPersonalRepository(user.username);\r
index ce72a46f94b6482ee2c22d6f35a723ab1e1d4acf..375dbd5a109293ba5e1132c9023ceb58b20ec37f 100644 (file)
@@ -118,11 +118,11 @@ public class JGitUtilsTest {
 \r
        @Test\r
        public void testLastCommit() throws Exception {\r
-               assertEquals(new Date(0), JGitUtils.getLastChange(null));\r
+               assertEquals(new Date(0), JGitUtils.getLastChange(null).when);\r
 \r
                Repository repository = GitBlitSuite.getHelloworldRepository();\r
                assertTrue(JGitUtils.getCommit(repository, null) != null);\r
-               Date date = JGitUtils.getLastChange(repository);\r
+               Date date = JGitUtils.getLastChange(repository).when;\r
                repository.close();\r
                assertNotNull("Could not get last repository change date!", date);\r
        }\r
@@ -140,7 +140,7 @@ public class JGitUtilsTest {
                        assertNull(JGitUtils.getFirstCommit(repository, null));\r
                        assertEquals(folder.lastModified(), JGitUtils.getFirstChange(repository, null)\r
                                        .getTime());\r
-                       assertEquals(folder.lastModified(), JGitUtils.getLastChange(repository).getTime());\r
+                       assertEquals(folder.lastModified(), JGitUtils.getLastChange(repository).when.getTime());\r
                        assertNull(JGitUtils.getCommit(repository, null));\r
                        repository.close();\r
                        RepositoryCache.close(repository);\r