Added UI for the push log introduced in 1.2.1
2 files added
10 files modified
| | |
| | | - Updated Japanese translation
|
| | |
|
| | | additions:
|
| | | - Added a ui for the push log introduced in 1.2.1 (issue-177)
|
| | | - Added client application menus for Git, SourceTree, Tower, GitHub for Windows, GitHub for Mac, and SparkleShare
|
| | | - Added GO http/https connector thread pool size setting
|
| | | - Added a server setting to force a particular translation/Locale for all sessions
|
| | |
| | | - { name: 'git.defaultIncrementalPushTagPrefix', defaultValue: 'r' }
|
| | | - { name: 'web.allowAppCloneLinks', defaultValue: true }
|
| | | - { name: 'web.forceDefaultLocale', defaultValue: ' ' }
|
| | | - { name: 'web.overviewPushCount', defaultValue: 5 }
|
| | | - { name: 'web.pushesPerPage', defaultValue: 10 }
|
| | | - { name: 'server.nioThreadPoolSize', defaultValue: 50 }
|
| | | }
|
| | |
|
| | |
| | | web.summaryRefsCount = 5
|
| | |
|
| | | # The number of items to show on a page before showing the first, prev, next
|
| | | # pagination links. A default if 50 is used for any invalid value.
|
| | | # pagination links. A default of 50 is used for any invalid value.
|
| | | #
|
| | | # SINCE 0.5.0
|
| | | web.itemsPerPage = 50
|
| | |
|
| | | # The number of pushes to display on the overview page
|
| | | # Value must exceed 0 else default of 5 is used
|
| | | #
|
| | | # SINCE 1.3.0
|
| | | web.overviewPushCount = 5
|
| | |
|
| | | # The number of pushes to show on a push page before show the first, prev, next
|
| | | # pagination links. A default of 10 is used for any invalid value.
|
| | | #
|
| | | # SINCE 1.3.0
|
| | | web.pushesPerPage = 10
|
| | |
|
| | | # Registered file extensions to ignore during Lucene indexing
|
| | | #
|
| | | # SPACE-DELIMITED
|
| | |
| | | import org.eclipse.jgit.revwalk.RevCommit;
|
| | | import org.eclipse.jgit.transport.ReceiveCommand;
|
| | |
|
| | | import com.gitblit.utils.StringUtils;
|
| | |
|
| | | /**
|
| | | * Model class to represent a push into a repository.
|
| | | *
|
| | |
| | |
|
| | | private final Map<String, ReceiveCommand.Type> refUpdates;
|
| | |
|
| | | private final Map<String, String> refIdChanges;
|
| | |
|
| | | /**
|
| | | * Constructor for specified duration of push from start date.
|
| | | *
|
| | |
| | | this.user = user;
|
| | | this.commits = new LinkedHashSet<RepositoryCommit>();
|
| | | this.refUpdates = new HashMap<String, ReceiveCommand.Type>();
|
| | | this.refIdChanges = new HashMap<String, String>();
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | if (!refUpdates.containsKey(ref)) {
|
| | | refUpdates.put(ref, type);
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * Tracks the change type for the specified ref.
|
| | | * |
| | | * @param ref
|
| | | * @param type
|
| | | * @param oldId
|
| | | * @param newId
|
| | | */
|
| | | public void updateRef(String ref, ReceiveCommand.Type type, String oldId, String newId) {
|
| | | if (!refUpdates.containsKey(ref)) {
|
| | | refUpdates.put(ref, type);
|
| | | refIdChanges.put(ref, oldId + "-" + newId);
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * Returns the old id of a ref.
|
| | | * |
| | | * @param ref
|
| | | * @return the old id
|
| | | */
|
| | | public String getOldId(String ref) {
|
| | | String change = refIdChanges.get(ref);
|
| | | if (StringUtils.isEmpty(change)) {
|
| | | return null;
|
| | | }
|
| | | return change.split("-")[0];
|
| | | }
|
| | |
|
| | | /**
|
| | | * Returns the new id of a ref
|
| | | * |
| | | * @param ref
|
| | | * @return the new id
|
| | | */
|
| | | public String getNewId(String ref) {
|
| | | String change = refIdChanges.get(ref);
|
| | | if (StringUtils.isEmpty(change)) {
|
| | | return null;
|
| | | }
|
| | | return change.split("-")[1];
|
| | | }
|
| | | |
| | | /**
|
| | | * Returns the change type of the ref change.
|
| | | * |
| | | * @param ref
|
| | | * @return the change type for the ref
|
| | | */
|
| | | public ReceiveCommand.Type getChangeType(String ref) {
|
| | | ReceiveCommand.Type type = refUpdates.get(ref);
|
| | | return type;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * Adds a a list of repository commits. This is used to construct discrete
|
| | | * ref push log entries
|
| | | * |
| | | * @param commits
|
| | | */
|
| | | public void addCommits(List<RepositoryCommit> list) {
|
| | | commits.addAll(list);
|
| | | }
|
| | | |
| | | /**
|
| | | * Returns true if this push contains a non-fastforward ref update.
|
| | | *
|
| | | * @return true if this is a non-fastforward push
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * Returns true if this ref has been rewound.
|
| | | * |
| | | * @param ref
|
| | | * @return true if this is a non-fastforward ref update
|
| | | */
|
| | | public boolean isNonFastForward(String ref) {
|
| | | ReceiveCommand.Type type = refUpdates.get(ref);
|
| | | if (type == null) {
|
| | | return false;
|
| | | }
|
| | | return ReceiveCommand.Type.UPDATE_NONFASTFORWARD.equals(type);
|
| | | }
|
| | |
|
| | | /**
|
| | | * Returns true if this ref has been deleted.
|
| | | * |
| | | * @param ref
|
| | | * @return true if this is a delete ref update
|
| | | */
|
| | | public boolean isDelete(String ref) {
|
| | | ReceiveCommand.Type type = refUpdates.get(ref);
|
| | | if (type == null) {
|
| | | return false;
|
| | | }
|
| | | return ReceiveCommand.Type.DELETE.equals(type);
|
| | | }
|
| | | |
| | | /**
|
| | | * Returns the list of refs changed by the push.
|
| | | * |
| | | * @return a list of refs
|
| | | */
|
| | | public List<String> getChangedRefs() {
|
| | | return new ArrayList<String>(refUpdates.keySet());
|
| | | }
|
| | | |
| | | /**
|
| | | * Returns the list of branches changed by the push.
|
| | | *
|
| | | * @return a list of branches
|
| | |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.TreeSet; |
| | | |
| | |
| | | import com.gitblit.models.PathModel.PathChangeModel; |
| | | import com.gitblit.models.PushLogEntry; |
| | | import com.gitblit.models.RefModel; |
| | | import com.gitblit.models.RepositoryCommit; |
| | | import com.gitblit.models.UserModel; |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | public static List<PushLogEntry> getPushLog(String repositoryName, Repository repository) { |
| | | return getPushLog(repositoryName, repository, null, -1); |
| | | return getPushLog(repositoryName, repository, null, 0, -1); |
| | | } |
| | | |
| | | public static List<PushLogEntry> getPushLog(String repositoryName, Repository repository, int maxCount) { |
| | | return getPushLog(repositoryName, repository, null, maxCount); |
| | | return getPushLog(repositoryName, repository, null, 0, maxCount); |
| | | } |
| | | |
| | | public static List<PushLogEntry> getPushLog(String repositoryName, Repository repository, int offset, int maxCount) { |
| | | return getPushLog(repositoryName, repository, null, offset, maxCount); |
| | | } |
| | | |
| | | public static List<PushLogEntry> getPushLog(String repositoryName, Repository repository, Date minimumDate) { |
| | | return getPushLog(repositoryName, repository, minimumDate, -1); |
| | | return getPushLog(repositoryName, repository, minimumDate, 0, -1); |
| | | } |
| | | |
| | | public static List<PushLogEntry> getPushLog(String repositoryName, Repository repository, Date minimumDate, int maxCount) { |
| | | /** |
| | | * Returns the list of push log entries as they were recorded by Gitblit. |
| | | * Each PushLogEntry may represent multiple ref updates. |
| | | * |
| | | * @param repositoryName |
| | | * @param repository |
| | | * @param minimumDate |
| | | * @param offset |
| | | * @param maxCount |
| | | * if < 0, all pushes are returned. |
| | | * @return a list of push log entries |
| | | */ |
| | | public static List<PushLogEntry> getPushLog(String repositoryName, Repository repository, |
| | | Date minimumDate, int offset, int maxCount) { |
| | | List<PushLogEntry> list = new ArrayList<PushLogEntry>(); |
| | | RefModel ref = getPushLogBranch(repository); |
| | | if (ref == null) { |
| | | return list; |
| | | } |
| | | if (maxCount == 0) { |
| | | return list; |
| | | } |
| | | |
| | | Map<ObjectId, List<RefModel>> allRefs = JGitUtils.getAllRefs(repository); |
| | | List<RevCommit> pushes; |
| | | if (minimumDate == null) { |
| | | pushes = JGitUtils.getRevLog(repository, GB_PUSHES, 0, maxCount); |
| | | pushes = JGitUtils.getRevLog(repository, GB_PUSHES, offset, maxCount); |
| | | } else { |
| | | pushes = JGitUtils.getRevLog(repository, GB_PUSHES, minimumDate); |
| | | } |
| | |
| | | default: |
| | | String content = JGitUtils.getStringContent(repository, push.getTree(), change.path); |
| | | String [] fields = content.split(" "); |
| | | log.updateRef(change.path, ReceiveCommand.Type.valueOf(fields[0])); |
| | | String oldId = fields[1]; |
| | | String newId = fields[2]; |
| | | log.updateRef(change.path, ReceiveCommand.Type.valueOf(fields[0]), oldId, newId); |
| | | List<RevCommit> pushedCommits = JGitUtils.getRevLog(repository, oldId, newId); |
| | | for (RevCommit pushedCommit : pushedCommits) { |
| | | log.addCommit(change.path, pushedCommit); |
| | | RepositoryCommit repoCommit = log.addCommit(change.path, pushedCommit); |
| | | if (repoCommit != null) { |
| | | repoCommit.setRefs(allRefs.get(pushedCommit.getId())); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | Collections.sort(list); |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * Returns the list of pushes separated by ref (e.g. each ref has it's own |
| | | * PushLogEntry object). |
| | | * |
| | | * @param repositoryName |
| | | * @param repository |
| | | * @param maxCount |
| | | * @return a list of push log entries separated by ref |
| | | */ |
| | | public static List<PushLogEntry> getPushLogByRef(String repositoryName, Repository repository, int maxCount) { |
| | | return getPushLogByRef(repositoryName, repository, 0, maxCount); |
| | | } |
| | | |
| | | /** |
| | | * Returns the list of pushes separated by ref (e.g. each ref has it's own |
| | | * PushLogEntry object). |
| | | * |
| | | * @param repositoryName |
| | | * @param repository |
| | | * @param offset |
| | | * @param maxCount |
| | | * @return a list of push log entries separated by ref |
| | | */ |
| | | public static List<PushLogEntry> getPushLogByRef(String repositoryName, Repository repository, int offset, |
| | | int maxCount) { |
| | | // break the push log into ref push logs and then merge them back into a list |
| | | Map<String, List<PushLogEntry>> refMap = new HashMap<String, List<PushLogEntry>>(); |
| | | for (PushLogEntry push : getPushLog(repositoryName, repository, offset, maxCount)) { |
| | | for (String ref : push.getChangedRefs()) { |
| | | if (!refMap.containsKey(ref)) { |
| | | refMap.put(ref, new ArrayList<PushLogEntry>()); |
| | | } |
| | | |
| | | // construct new ref-specific push log entry |
| | | PushLogEntry refPush = new PushLogEntry(push.repository, push.date, push.user); |
| | | refPush.updateRef(ref, push.getChangeType(ref), push.getOldId(ref), push.getNewId(ref)); |
| | | refPush.addCommits(push.getCommits(ref)); |
| | | refMap.get(ref).add(refPush); |
| | | } |
| | | } |
| | | |
| | | // merge individual ref pushes into master list |
| | | List<PushLogEntry> refPushLog = new ArrayList<PushLogEntry>(); |
| | | for (List<PushLogEntry> refPush : refMap.values()) { |
| | | refPushLog.addAll(refPush); |
| | | } |
| | | |
| | | // sort ref push log |
| | | Collections.sort(refPushLog); |
| | | |
| | | return refPushLog; |
| | | } |
| | | } |
| | |
| | | import com.gitblit.wicket.pages.PatchPage;
|
| | | import com.gitblit.wicket.pages.ProjectPage;
|
| | | import com.gitblit.wicket.pages.ProjectsPage;
|
| | | import com.gitblit.wicket.pages.PushesPage;
|
| | | import com.gitblit.wicket.pages.RawPage;
|
| | | import com.gitblit.wicket.pages.RepositoriesPage;
|
| | | import com.gitblit.wicket.pages.ReviewProposalPage;
|
| | |
| | | // mount("/repositories", RepositoriesPage.class);
|
| | | mount("/overview", OverviewPage.class, "r", "h");
|
| | | mount("/summary", SummaryPage.class, "r");
|
| | | mount("/pushes", PushesPage.class, "r", "h");
|
| | | mount("/commits", LogPage.class, "r", "h");
|
| | | mount("/log", LogPage.class, "r", "h");
|
| | | mount("/tags", TagsPage.class, "r");
|
| | |
| | | gb.manual = manual
|
| | | gb.from = from
|
| | | gb.to = to |
| | | gb.at = at
|
| | | gb.morePushes = all pushes...
|
| | | gb.pushes = pushes
|
| | | gb.pushedNCommitsTo = pushed {0} commits to
|
| | | gb.pushedOneCommitTo = pushed 1 commit to
|
| | | gb.viewComparison = view comparison of these {0} commits \u00bb
|
| | | gb.nMoreCommits = {0} more commits \u00bb
|
| | | gb.oneMoreCommit = 1 more commit \u00bb
|
| | | gb.pushedNewTag = pushed new tag
|
| | | gb.deletedTag = deleted tag
|
| | | gb.pushedNewBranch = pushed new branch
|
| | | gb.deletedBranch = deleted branch
|
| | | gb.rewind = REWIND |
| | |
| | |
|
| | | add(new RepositoryUrlPanel("repositoryUrlPanel", false, user, model));
|
| | |
|
| | | PushesPanel pushes = new PushesPanel("pushesPanel", getRepositoryModel(), r, 10, 0);
|
| | | int pushCount = GitBlit.getInteger(Keys.web.overviewPushCount, 5);
|
| | | PushesPanel pushes = new PushesPanel("pushesPanel", getRepositoryModel(), r, pushCount, 0);
|
| | | add(pushes);
|
| | | add(new TagsPanel("tagsPanel", repositoryName, r, numberRefs).hideIfEmpty());
|
| | | add(new BranchesPanel("branchesPanel", getRepositoryModel(), r, numberRefs, false).hideIfEmpty());
|
New file |
| | |
| | | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
| | | <html xmlns="http://www.w3.org/1999/xhtml" |
| | | xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd" |
| | | xml:lang="en" |
| | | lang="en"> |
| | |
|
| | | <body>
|
| | | <wicket:extend>
|
| | |
|
| | | <!-- pager links -->
|
| | | <div class="page_nav2">
|
| | | <a wicket:id="firstPage"><wicket:message key="gb.pageFirst"></wicket:message></a> | <a wicket:id="prevPage">« <wicket:message key="gb.pagePrevious"></wicket:message></a> | <a wicket:id="nextPage"><wicket:message key="gb.pageNext"></wicket:message> »</a> |
| | | </div>
|
| | | |
| | | <!-- push log -->
|
| | | <div style="margin-top:5px;" wicket:id="pushesPanel">[push log panel]</div>
|
| | |
|
| | | <!-- pager links -->
|
| | | <div style="padding-bottom:5px;">
|
| | | <a wicket:id="firstPage"><wicket:message key="gb.pageFirst"></wicket:message></a> | <a wicket:id="prevPage">« <wicket:message key="gb.pagePrevious"></wicket:message></a> | <a wicket:id="nextPage"><wicket:message key="gb.pageNext"></wicket:message> »</a> |
| | | </div>
|
| | | |
| | | </wicket:extend>
|
| | | </body>
|
| | | </html> |
New file |
| | |
| | | /*
|
| | | * Copyright 2013 gitblit.com.
|
| | | *
|
| | | * Licensed under the Apache License, Version 2.0 (the "License");
|
| | | * you may not use this file except in compliance with the License.
|
| | | * You may obtain a copy of the License at
|
| | | *
|
| | | * http://www.apache.org/licenses/LICENSE-2.0
|
| | | *
|
| | | * Unless required by applicable law or agreed to in writing, software
|
| | | * distributed under the License is distributed on an "AS IS" BASIS,
|
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| | | * See the License for the specific language governing permissions and
|
| | | * limitations under the License.
|
| | | */
|
| | | package com.gitblit.wicket.pages;
|
| | |
|
| | | import org.apache.wicket.PageParameters;
|
| | | import org.apache.wicket.markup.html.link.BookmarkablePageLink;
|
| | |
|
| | | import com.gitblit.wicket.WicketUtils;
|
| | | import com.gitblit.wicket.panels.PushesPanel;
|
| | |
|
| | | public class PushesPage extends RepositoryPage {
|
| | |
|
| | | public PushesPage(PageParameters params) {
|
| | | super(params);
|
| | |
|
| | | addSyndicationDiscoveryLink();
|
| | |
|
| | | int pageNumber = WicketUtils.getPage(params);
|
| | | int prevPage = Math.max(0, pageNumber - 1);
|
| | | int nextPage = pageNumber + 1;
|
| | |
|
| | | PushesPanel pushesPanel = new PushesPanel("pushesPanel", getRepositoryModel(), getRepository(), -1,
|
| | | pageNumber - 1);
|
| | | boolean hasMore = pushesPanel.hasMore();
|
| | | add(pushesPanel);
|
| | |
|
| | | add(new BookmarkablePageLink<Void>("firstPage", PushesPage.class,
|
| | | WicketUtils.newObjectParameter(repositoryName, objectId))
|
| | | .setEnabled(pageNumber > 1));
|
| | | add(new BookmarkablePageLink<Void>("prevPage", PushesPage.class,
|
| | | WicketUtils.newLogPageParameter(repositoryName, objectId, prevPage))
|
| | | .setEnabled(pageNumber > 1));
|
| | | add(new BookmarkablePageLink<Void>("nextPage", PushesPage.class,
|
| | | WicketUtils.newLogPageParameter(repositoryName, objectId, nextPage))
|
| | | .setEnabled(hasMore));
|
| | | }
|
| | |
|
| | | @Override
|
| | | protected String getPageName() {
|
| | | return getString("gb.pushes");
|
| | | }
|
| | | }
|
| | |
| | | } else {
|
| | | pages.put("summary", new PageRegistration("gb.summary", SummaryPage.class, params));
|
| | | // pages.put("overview", new PageRegistration("gb.overview", OverviewPage.class, params));
|
| | | pages.put("pushes", new PageRegistration("gb.pushes", PushesPage.class, params));
|
| | | }
|
| | | pages.put("commits", new PageRegistration("gb.commits", LogPage.class, params));
|
| | | pages.put("tree", new PageRegistration("gb.tree", TreePage.class, params));
|
| | |
| | |
|
| | | <body>
|
| | | <wicket:panel>
|
| | | <div wicket:id="push">
|
| | | <div wicket:id="push" style="border-bottom: 1px solid #ddd;margin-bottom: 15px;">
|
| | | <table style="padding: 3px 0px;">
|
| | | <tr>
|
| | | <td class="hidden-phone" style="vertical-align: top;"><span wicket:id="whoAvatar"></span></td>
|
| | | <td style="padding-left: 7px;">
|
| | | <div><span wicket:id="whoPushed">[pusher]</span> <span wicket:id="whatPushed"></span><span wicket:id="wherePushed"></span></div>
|
| | | <div wicket:id="whenPushed"></div>
|
| | | <button type="button" class="btn btn-mini" style="padding: 1px 3px;line-height: 12px;" data-toggle="collapse" data-target="#demo"><span class="caret"></span></button>
|
| | | <div id="demo" class="collapse">
|
| | | <div style="padding: 10px 0px;">
|
| | | <div>
|
| | | <span wicket:id="whenPushed"></span> <span wicket:id="refRewind" class="alert alert-error" style="padding: 1px 5px;font-size: 10px;font-weight: bold;margin-left: 10px;">[rewind]</span>
|
| | | </div>
|
| | | <div style="font-weight:bold;"><span wicket:id="whoPushed">[pusher]</span> <span wicket:id="whatPushed"></span><span wicket:id="refPushed"></span> <span wicket:id="repoPreposition"></span> <span wicket:id="repoPushed"></span></div>
|
| | | <div style="padding: 10px 0px 5px;">
|
| | | <table>
|
| | | <tr wicket:id="commit" style="border-left: 1px solid #ddd;">
|
| | | <td style="vertical-align:top;"><span wicket:id="hashLink" style="padding-left: 10px;">[hash link]</span></td>
|
| | | <td><img wicket:id="commitIcon" /></td>
|
| | | <tr wicket:id="commit">
|
| | | <td style="vertical-align:top;"><span wicket:id="commitAuthor"></span></td>
|
| | | <td style="vertical-align:top;"><span wicket:id="hashLink" style="padding-left: 5px;">[hash link]</span></td>
|
| | | <td style="vertical-align:top;"><img wicket:id="commitIcon" /></td>
|
| | | <td style="vertical-align:top;">
|
| | | <div wicket:id="commitShortMessage">[commit short message]</div>
|
| | | <div wicket:id="commitRefs">[commit refs]</div>
|
| | | <span wicket:id="commitShortMessage">[commit short message]</span>
|
| | | </td>
|
| | | </tr>
|
| | | </table>
|
| | | </div>
|
| | | <span class="link" wicket:id="compareLink"></span>
|
| | | </div>
|
| | | </td>
|
| | | </tr>
|
| | | </table>
|
| | | </div>
|
| | | <div wicket:id="morePushes">[more...]</div>
|
| | | </wicket:panel>
|
| | | </body>
|
| | | </html> |
| | |
| | | /*
|
| | | * Copyright 2011 gitblit.com.
|
| | | * Copyright 2013 gitblit.com.
|
| | | *
|
| | | * Licensed under the Apache License, Version 2.0 (the "License");
|
| | | * you may not use this file except in compliance with the License.
|
| | |
| | | package com.gitblit.wicket.panels;
|
| | |
|
| | | import java.text.MessageFormat;
|
| | | import java.util.HashMap;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import org.apache.wicket.markup.html.basic.Label;
|
| | | import org.apache.wicket.markup.repeater.Item;
|
| | | import org.apache.wicket.markup.repeater.data.DataView;
|
| | | import org.apache.wicket.markup.repeater.data.ListDataProvider;
|
| | | import org.apache.wicket.model.StringResourceModel;
|
| | | import org.eclipse.jgit.lib.Repository;
|
| | |
|
| | | import com.gitblit.Constants;
|
| | |
| | | import com.gitblit.models.PushLogEntry;
|
| | | import com.gitblit.models.RepositoryCommit;
|
| | | import com.gitblit.models.RepositoryModel;
|
| | | import com.gitblit.models.UserModel;
|
| | | import com.gitblit.utils.PushLogUtils;
|
| | | import com.gitblit.utils.StringUtils;
|
| | | import com.gitblit.wicket.WicketUtils;
|
| | | import com.gitblit.wicket.pages.CommitPage;
|
| | | import com.gitblit.wicket.pages.GitSearchPage;
|
| | | import com.gitblit.wicket.pages.ComparePage;
|
| | | import com.gitblit.wicket.pages.PushesPage;
|
| | | import com.gitblit.wicket.pages.SummaryPage;
|
| | | import com.gitblit.wicket.pages.TagPage;
|
| | | import com.gitblit.wicket.pages.TreePage;
|
| | | import com.gitblit.wicket.pages.UserPage;
|
| | |
|
| | | public class PushesPanel extends BasePanel {
|
| | |
| | | public PushesPanel(String wicketId, final RepositoryModel model, Repository r, int limit, int pageOffset) {
|
| | | super(wicketId);
|
| | | boolean pageResults = limit <= 0;
|
| | | int itemsPerPage = GitBlit.getInteger(Keys.web.itemsPerPage, 50);
|
| | | if (itemsPerPage <= 1) {
|
| | | itemsPerPage = 50;
|
| | | int pushesPerPage = GitBlit.getInteger(Keys.web.pushesPerPage, 10);
|
| | | if (pushesPerPage <= 1) {
|
| | | pushesPerPage = 10;
|
| | | }
|
| | |
|
| | | final Map<String, String> usernameLookup = new HashMap<String, String>();
|
| | | final int hashLen = GitBlit.getInteger(Keys.web.shortCommitIdLength, 6);
|
| | | List<PushLogEntry> entries = PushLogUtils.getPushLog(model.name, r, limit);
|
| | | // establish pusher identities
|
| | | for (PushLogEntry push : entries) {
|
| | | // handle push logs with email address instead of account name
|
| | | String username = push.user.username;
|
| | | if (push.user.username.indexOf('@') > -1) {
|
| | | // push username is an email address, reverse lookup for account
|
| | | if (!usernameLookup.containsKey(push.user.username)) {
|
| | | for (UserModel user : GitBlit.self().getAllUsers()) {
|
| | | if (push.user.username.equals(user.emailAddress)) {
|
| | | username = user.username;
|
| | | usernameLookup.put(push.user.username, username);
|
| | | break;
|
| | | }
|
| | | }
|
| | | List<PushLogEntry> pushes;
|
| | | if (pageResults) {
|
| | | pushes = PushLogUtils.getPushLogByRef(model.name, r, pageOffset * pushesPerPage, pushesPerPage);
|
| | | } else {
|
| | | username = usernameLookup.get(push.user.username);
|
| | | }
|
| | | } else {
|
| | | // push username is an account name, lookup for email address
|
| | | if (!usernameLookup.containsKey(push.user.username)) {
|
| | | UserModel user = GitBlit.self().getUserModel(push.user.username);
|
| | | if (user != null) {
|
| | | push.user.emailAddress = user.emailAddress;
|
| | | usernameLookup.put(push.user.username, user.emailAddress);
|
| | | }
|
| | | } else {
|
| | | push.user.emailAddress = usernameLookup.get(push.user.username);
|
| | | }
|
| | | }
|
| | | pushes = PushLogUtils.getPushLogByRef(model.name, r, limit);
|
| | | }
|
| | |
|
| | | hasPushes = entries.size() > 0;
|
| | | // inaccurate way to determine if there are more commits.
|
| | | // works unless commits.size() represents the exact end.
|
| | | hasMore = pushes.size() >= pushesPerPage;
|
| | |
|
| | | ListDataProvider<PushLogEntry> dp = new ListDataProvider<PushLogEntry>(entries);
|
| | | hasPushes = pushes.size() > 0;
|
| | |
|
| | | ListDataProvider<PushLogEntry> dp = new ListDataProvider<PushLogEntry>(pushes);
|
| | | DataView<PushLogEntry> pushView = new DataView<PushLogEntry>("push", dp) {
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | public void populateItem(final Item<PushLogEntry> pushItem) {
|
| | | final PushLogEntry push = pushItem.getModelObject();
|
| | | String fullRefName = push.getChangedRefs().get(0);
|
| | | String shortRefName = fullRefName;
|
| | | boolean isTag = false;
|
| | | if (shortRefName.startsWith(org.eclipse.jgit.lib.Constants.R_HEADS)) {
|
| | | shortRefName = shortRefName.substring(org.eclipse.jgit.lib.Constants.R_HEADS.length());
|
| | | } else if (shortRefName.startsWith(org.eclipse.jgit.lib.Constants.R_TAGS)) {
|
| | | shortRefName = shortRefName.substring(org.eclipse.jgit.lib.Constants.R_TAGS.length());
|
| | | isTag = true;
|
| | | }
|
| | |
|
| | | |
| | | pushItem.add(WicketUtils.createDateLabel("whenPushed", push.date, getTimeZone(), getTimeUtils()));
|
| | | pushItem.add(new GravatarImage("whoAvatar", push.getCommitterIdent(), 40));
|
| | | if (push.user.username.equals(push.user.emailAddress) && push.user.emailAddress.indexOf('@') > -1) {
|
| | | // username is an email address - 1.2.1 push log bug
|
| | | pushItem.add(new Label("whoPushed", push.user.getDisplayName()));
|
| | | } else {
|
| | | // link to user acount page
|
| | | pushItem.add(new LinkPanel("whoPushed", null, push.user.getDisplayName(),
|
| | | UserPage.class, WicketUtils.newUsernameParameter(push.user.username)));
|
| | | pushItem.add(new Label("whatPushed", |
| | | MessageFormat.format(push.getCommitCount() > 1 ? "pushed {0} commits to":"pushed 1 commit to", push.getCommitCount())));
|
| | | String repoName = StringUtils.stripDotGit(model.name);
|
| | | pushItem.add(new LinkPanel("wherePushed", null, repoName,
|
| | | SummaryPage.class, WicketUtils.newRepositoryParameter(model.name)));
|
| | | pushItem.add(WicketUtils.createDateLabel("whenPushed", push.date, getTimeZone(), getTimeUtils()));
|
| | | }
|
| | |
|
| | | ListDataProvider<RepositoryCommit> cdp = new ListDataProvider<RepositoryCommit>(push.getCommits());
|
| | | String preposition = "gb.at";
|
| | | boolean isDelete = false;
|
| | | boolean isRewind = false;
|
| | | String what;
|
| | | switch(push.getChangeType(fullRefName)) {
|
| | | case CREATE:
|
| | | if (isTag) {
|
| | | what = getString("gb.pushedNewTag");
|
| | | } else {
|
| | | what = getString("gb.pushedNewBranch");
|
| | | }
|
| | | preposition = "gb.to";
|
| | | break;
|
| | | case DELETE:
|
| | | isDelete = true;
|
| | | if (isTag) {
|
| | | what = getString("gb.deletedTag");
|
| | | } else {
|
| | | what = getString("gb.deletedBranch");
|
| | | }
|
| | | preposition = "gb.from";
|
| | | break;
|
| | | case UPDATE_NONFASTFORWARD:
|
| | | isRewind = true;
|
| | | default:
|
| | | what = MessageFormat.format(push.getCommitCount() > 1 ? getString("gb.pushedNCommitsTo") : getString("gb.pushedOneCommitTo") , push.getCommitCount());
|
| | | break;
|
| | | }
|
| | | pushItem.add(new Label("whatPushed", what));
|
| | | |
| | | pushItem.add(new Label("refRewind", getString("gb.rewind")).setVisible(isRewind));
|
| | | |
| | | if (isDelete) {
|
| | | // can't link to deleted ref
|
| | | pushItem.add(new Label("refPushed", shortRefName));
|
| | | } else if (isTag) {
|
| | | // link to tag
|
| | | pushItem.add(new LinkPanel("refPushed", null, shortRefName,
|
| | | TagPage.class, WicketUtils.newObjectParameter(model.name, fullRefName)));
|
| | | } else {
|
| | | // link to tree
|
| | | pushItem.add(new LinkPanel("refPushed", null, shortRefName,
|
| | | TreePage.class, WicketUtils.newObjectParameter(model.name, fullRefName)));
|
| | | }
|
| | | |
| | | // to/from/etc
|
| | | pushItem.add(new Label("repoPreposition", getString(preposition)));
|
| | | |
| | | String repoName = StringUtils.stripDotGit(model.name);
|
| | | pushItem.add(new LinkPanel("repoPushed", null, repoName,
|
| | | SummaryPage.class, WicketUtils.newRepositoryParameter(model.name)));
|
| | |
|
| | | int maxCommitCount = 5;
|
| | | List<RepositoryCommit> commits = push.getCommits();
|
| | | if (commits.size() > maxCommitCount) {
|
| | | commits = new ArrayList<RepositoryCommit>(commits.subList(0, maxCommitCount)); |
| | | }
|
| | | |
| | | // compare link
|
| | | String compareLinkText = null;
|
| | | if ((push.getCommitCount() <= maxCommitCount) && (push.getCommitCount() > 1)) {
|
| | | compareLinkText = MessageFormat.format(getString("gb.viewComparison"), commits.size());
|
| | | } else if (push.getCommitCount() > maxCommitCount) {
|
| | | int diff = push.getCommitCount() - maxCommitCount;
|
| | | compareLinkText = MessageFormat.format(diff > 1 ? getString("gb.nMoreCommits") : getString("gb.oneMoreCommit"), diff);
|
| | | }
|
| | | if (StringUtils.isEmpty(compareLinkText)) {
|
| | | pushItem.add(new Label("compareLink").setVisible(false));
|
| | | } else {
|
| | | String endRangeId = push.getNewId(fullRefName);
|
| | | String startRangeId = push.getOldId(fullRefName);
|
| | | pushItem.add(new LinkPanel("compareLink", null, compareLinkText, ComparePage.class, WicketUtils.newRangeParameter(push.repository, startRangeId, endRangeId)));
|
| | | }
|
| | | |
| | | ListDataProvider<RepositoryCommit> cdp = new ListDataProvider<RepositoryCommit>(commits);
|
| | | DataView<RepositoryCommit> commitsView = new DataView<RepositoryCommit>("commit", cdp) {
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | public void populateItem(final Item<RepositoryCommit> commitItem) {
|
| | | final RepositoryCommit commit = commitItem.getModelObject();
|
| | |
|
| | | // author search link
|
| | | String author = commit.getAuthorIdent().getName();
|
| | | LinkPanel authorLink = new LinkPanel("commitAuthor", "list", author,
|
| | | GitSearchPage.class, WicketUtils.newSearchParameter(model.name,
|
| | | null, author, Constants.SearchType.AUTHOR));
|
| | | setPersonSearchTooltip(authorLink, author, Constants.SearchType.AUTHOR);
|
| | | commitItem.add(authorLink);
|
| | | // author gravatar
|
| | | commitItem.add(new GravatarImage("commitAuthor", commit.getAuthorIdent().getName(),
|
| | | commit.getAuthorIdent().getEmailAddress(), null, 16, false, false));
|
| | |
|
| | | // merge icon
|
| | | if (commit.getParentCount() > 1) {
|
| | |
| | | }
|
| | | commitItem.add(shortlog);
|
| | |
|
| | | commitItem.add(new RefsPanel("commitRefs", commit.repository, commit.getRefs()));
|
| | |
|
| | | // commit hash link
|
| | | LinkPanel commitHash = new LinkPanel("hashLink", null, commit.getName().substring(0, hashLen),
|
| | | CommitPage.class, WicketUtils.newObjectParameter(
|
| | |
| | | WicketUtils.setCssClass(commitHash, "shortsha1");
|
| | | WicketUtils.setHtmlTooltip(commitHash, commit.getName());
|
| | | commitItem.add(commitHash);
|
| | | |
| | | // item.add(new BookmarkablePageLink<Void>("diff", CommitDiffPage.class, WicketUtils
|
| | | // .newObjectParameter(repositoryName, entry.getName())).setEnabled(entry
|
| | | // .getParentCount() > 0));
|
| | | // item.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils
|
| | | // .newObjectParameter(repositoryName, entry.getName())));
|
| | | }
|
| | | };
|
| | |
|
| | |
| | | add(pushView);
|
| | |
|
| | | // determine to show pager, more, or neither
|
| | | // if (limit <= 0) {
|
| | | // // no display limit
|
| | | // add(new Label("moreLogs", "").setVisible(false));
|
| | | // } else {
|
| | | // if (pageResults) {
|
| | | // // paging
|
| | | // add(new Label("moreLogs", "").setVisible(false));
|
| | | // } else {
|
| | | // // more
|
| | | // if (commits.size() == limit) {
|
| | | // // show more
|
| | | // add(new LinkPanel("moreLogs", "link", new StringResourceModel("gb.moreLogs",
|
| | | // this, null), LogPage.class,
|
| | | // WicketUtils.newRepositoryParameter(repositoryName)));
|
| | | // } else {
|
| | | // // no more
|
| | | // add(new Label("moreLogs", "").setVisible(false));
|
| | | // }
|
| | | // }
|
| | | // }
|
| | | if (limit <= 0) {
|
| | | // no display limit
|
| | | add(new Label("morePushes").setVisible(false));
|
| | | } else {
|
| | | if (pageResults) {
|
| | | // paging
|
| | | add(new Label("morePushes").setVisible(false));
|
| | | } else {
|
| | | // more
|
| | | if (pushes.size() == limit) {
|
| | | // show more
|
| | | add(new LinkPanel("morePushes", "link", new StringResourceModel("gb.morePushes",
|
| | | this, null), PushesPage.class,
|
| | | WicketUtils.newRepositoryParameter(model.name)));
|
| | | } else {
|
| | | // no more
|
| | | add(new Label("morePushes").setVisible(false));
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public boolean hasMore() {
|