| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 1 | // Copyright 2012 Google Inc. All Rights Reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package com.google.gitiles; |
| 16 | |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 17 | import static com.google.common.base.Preconditions.checkState; |
| Dave Borowitz | d6184a6 | 2013-01-10 11:53:54 -0800 | [diff] [blame] | 18 | import static org.eclipse.jgit.diff.DiffEntry.ChangeType.COPY; |
| 19 | import static org.eclipse.jgit.diff.DiffEntry.ChangeType.DELETE; |
| 20 | import static org.eclipse.jgit.diff.DiffEntry.ChangeType.RENAME; |
| 21 | |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 22 | import com.google.common.collect.ImmutableMap; |
| 23 | import com.google.common.collect.ImmutableSet; |
| 24 | import com.google.common.collect.Lists; |
| 25 | import com.google.common.collect.Maps; |
| Dave Borowitz | 75a7832 | 2014-03-16 12:13:08 -0700 | [diff] [blame] | 26 | import com.google.common.collect.Sets; |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 27 | import com.google.gitiles.CommitData.DiffList; |
| 28 | import com.google.gitiles.CommitData.Field; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 29 | import com.google.template.soy.data.restricted.NullData; |
| Dave Borowitz | 3b744b1 | 2016-08-19 16:11:10 -0400 | [diff] [blame] | 30 | import java.io.IOException; |
| 31 | import java.util.List; |
| 32 | import java.util.Map; |
| 33 | import java.util.Set; |
| 34 | import javax.annotation.Nullable; |
| 35 | import javax.servlet.http.HttpServletRequest; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 36 | import org.eclipse.jgit.diff.DiffEntry; |
| 37 | import org.eclipse.jgit.diff.DiffEntry.ChangeType; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 38 | import org.eclipse.jgit.lib.Constants; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 39 | import org.eclipse.jgit.lib.PersonIdent; |
| 40 | import org.eclipse.jgit.lib.Ref; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 41 | import org.eclipse.jgit.revwalk.RevCommit; |
| 42 | import org.eclipse.jgit.revwalk.RevWalk; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 43 | import org.eclipse.jgit.util.RelativeDateFormatter; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 44 | |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 45 | /** Soy data converter for git commits. */ |
| Dave Borowitz | 6ed598f | 2014-04-17 10:09:50 -0700 | [diff] [blame] | 46 | public class CommitSoyData { |
| Han-Wen Nienhuys | c0200f6 | 2016-05-02 17:34:51 +0200 | [diff] [blame] | 47 | static final ImmutableSet<Field> DEFAULT_FIELDS = |
| 48 | Sets.immutableEnumSet( |
| 49 | Field.AUTHOR, |
| 50 | Field.COMMITTER, |
| 51 | Field.SHA, |
| 52 | Field.TREE, |
| 53 | Field.TREE_URL, |
| 54 | Field.PARENTS, |
| 55 | Field.MESSAGE, |
| Pontus Jaensson | c144de9 | 2021-10-29 11:13:23 +0200 | [diff] [blame] | 56 | Field.NOTES, // Optional Field |
| Han-Wen Nienhuys | c0200f6 | 2016-05-02 17:34:51 +0200 | [diff] [blame] | 57 | Field.LOG_URL, |
| 58 | Field.ARCHIVE_URL, |
| 59 | Field.ARCHIVE_TYPE); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 60 | |
| Han-Wen Nienhuys | c0200f6 | 2016-05-02 17:34:51 +0200 | [diff] [blame] | 61 | private static final ImmutableSet<Field> NESTED_FIELDS = |
| 62 | Sets.immutableEnumSet(Field.PARENT_BLAME_URL); |
| Dave Borowitz | f03fcea | 2014-04-21 17:20:33 -0700 | [diff] [blame] | 63 | |
| Dave Borowitz | 3b086a7 | 2013-07-02 15:03:03 -0700 | [diff] [blame] | 64 | private Linkifier linkifier; |
| Gustaf Lundh | 06a9870 | 2015-08-17 17:29:11 +0200 | [diff] [blame] | 65 | private CommitData.Builder cdb; |
| Dave Borowitz | c8a1568 | 2013-07-02 14:33:08 -0700 | [diff] [blame] | 66 | private ArchiveFormat archiveFormat; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 67 | |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 68 | CommitSoyData setLinkifier(@Nullable Linkifier linkifier) { |
| 69 | this.linkifier = linkifier; |
| Dave Borowitz | 3b086a7 | 2013-07-02 15:03:03 -0700 | [diff] [blame] | 70 | return this; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 71 | } |
| 72 | |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 73 | CommitSoyData setArchiveFormat(@Nullable ArchiveFormat archiveFormat) { |
| 74 | this.archiveFormat = archiveFormat; |
| Dave Borowitz | c8a1568 | 2013-07-02 14:33:08 -0700 | [diff] [blame] | 75 | return this; |
| 76 | } |
| 77 | |
| Han-Wen Nienhuys | c0200f6 | 2016-05-02 17:34:51 +0200 | [diff] [blame] | 78 | Map<String, Object> toSoyData( |
| Jonathan Nieder | b49306a | 2019-03-07 14:10:57 -0800 | [diff] [blame] | 79 | HttpServletRequest req, RevWalk walk, RevCommit c, Set<Field> fs, DateFormatter df) |
| 80 | throws IOException { |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 81 | GitilesView view = ViewFilter.getView(req); |
| Gustaf Lundh | 06a9870 | 2015-08-17 17:29:11 +0200 | [diff] [blame] | 82 | if (cdb == null) { |
| 83 | cdb = new CommitData.Builder(); |
| 84 | } |
| 85 | |
| Jonathan Nieder | b49306a | 2019-03-07 14:10:57 -0800 | [diff] [blame] | 86 | CommitData cd = cdb.setArchiveFormat(archiveFormat).build(req, walk, c, fs); |
| Dave Borowitz | 3b086a7 | 2013-07-02 15:03:03 -0700 | [diff] [blame] | 87 | |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 88 | Map<String, Object> data = Maps.newHashMapWithExpectedSize(fs.size()); |
| 89 | if (cd.author != null) { |
| 90 | data.put("author", toSoyData(cd.author, df)); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 91 | } |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 92 | if (cd.committer != null) { |
| 93 | data.put("committer", toSoyData(cd.committer, df)); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 94 | } |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 95 | if (cd.sha != null) { |
| 96 | data.put("sha", cd.sha.name()); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 97 | } |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 98 | if (cd.abbrev != null) { |
| 99 | data.put("abbrevSha", cd.abbrev.name()); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 100 | } |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 101 | if (cd.url != null) { |
| 102 | data.put("url", cd.url); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 103 | } |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 104 | if (cd.logUrl != null) { |
| 105 | data.put("logUrl", cd.logUrl); |
| Dave Borowitz | c222cce | 2013-06-19 10:47:06 -0700 | [diff] [blame] | 106 | } |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 107 | if (cd.archiveUrl != null) { |
| 108 | data.put("archiveUrl", cd.archiveUrl); |
| Dave Borowitz | c8a1568 | 2013-07-02 14:33:08 -0700 | [diff] [blame] | 109 | } |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 110 | if (cd.archiveType != null) { |
| 111 | data.put("archiveType", cd.archiveType.getShortName()); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 112 | } |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 113 | if (cd.tree != null) { |
| 114 | data.put("tree", cd.tree.name()); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 115 | } |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 116 | if (cd.treeUrl != null) { |
| 117 | data.put("treeUrl", cd.treeUrl); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 118 | } |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 119 | if (cd.parents != null) { |
| Dave Borowitz | f03fcea | 2014-04-21 17:20:33 -0700 | [diff] [blame] | 120 | data.put("parents", toSoyData(view, fs, cd.parents)); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 121 | } |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 122 | if (cd.shortMessage != null) { |
| 123 | data.put("shortMessage", cd.shortMessage); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 124 | } |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 125 | if (cd.branches != null) { |
| 126 | data.put("branches", toSoyData(view, cd.branches, Constants.R_HEADS)); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 127 | } |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 128 | if (cd.tags != null) { |
| 129 | data.put("tags", toSoyData(view, cd.tags, Constants.R_TAGS)); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 130 | } |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 131 | if (cd.message != null) { |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 132 | if (linkifier != null) { |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 133 | data.put("message", linkifier.linkify(req, cd.message)); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 134 | } else { |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 135 | data.put("message", cd.message); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 136 | } |
| 137 | } |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 138 | if (cd.diffEntries != null) { |
| 139 | data.put("diffTree", toSoyData(view, cd.diffEntries)); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 140 | } |
| Pontus Jaensson | c144de9 | 2021-10-29 11:13:23 +0200 | [diff] [blame] | 141 | |
| 142 | int diffSetSize = Sets.difference(fs, NESTED_FIELDS).size(); |
| 143 | |
| 144 | if (fs.contains( |
| 145 | Field.NOTES)) { // Since NOTES is optional this is required for checkState to pass |
| 146 | diffSetSize -= 1; |
| 147 | } |
| 148 | |
| 149 | checkState(diffSetSize == data.size(), "bad commit data fields: %s != %s", fs, data.keySet()); |
| 150 | |
| 151 | if (cd.notes != null && !cd.notes.isEmpty()) { |
| 152 | data.put("notes", cd.notes); |
| 153 | } |
| 154 | |
| Michael Moss | 92bb12f | 2014-05-09 10:55:35 -0700 | [diff] [blame] | 155 | return data; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 156 | } |
| 157 | |
| Jonathan Nieder | b49306a | 2019-03-07 14:10:57 -0800 | [diff] [blame] | 158 | Map<String, Object> toSoyData( |
| 159 | HttpServletRequest req, RevWalk walk, RevCommit commit, DateFormatter df) throws IOException { |
| 160 | return toSoyData(req, walk, commit, DEFAULT_FIELDS, df); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | // TODO(dborowitz): Extract this. |
| Dave Borowitz | 97a7031 | 2014-04-28 15:50:23 -0700 | [diff] [blame] | 164 | public static Map<String, String> toSoyData(PersonIdent ident, DateFormatter df) { |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 165 | return ImmutableMap.of( |
| 166 | "name", ident.getName(), |
| 167 | "email", ident.getEmailAddress(), |
| Dave Borowitz | 97a7031 | 2014-04-28 15:50:23 -0700 | [diff] [blame] | 168 | "time", df.format(ident), |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 169 | // TODO(dborowitz): Switch from relative to absolute at some threshold. |
| 170 | "relativeTime", RelativeDateFormatter.format(ident.getWhen())); |
| 171 | } |
| 172 | |
| Han-Wen Nienhuys | c0200f6 | 2016-05-02 17:34:51 +0200 | [diff] [blame] | 173 | private List<Map<String, String>> toSoyData( |
| 174 | GitilesView view, Set<Field> fs, List<RevCommit> parents) { |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 175 | List<Map<String, String>> result = Lists.newArrayListWithCapacity(parents.size()); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 176 | int i = 1; |
| 177 | // TODO(dborowitz): Render something slightly different when we're actively |
| 178 | // viewing a diff against one of the parents. |
| 179 | for (RevCommit parent : parents) { |
| 180 | String name = parent.name(); |
| Dave Borowitz | 359ad6d | 2014-04-21 16:07:59 -0700 | [diff] [blame] | 181 | // Clear path on parent diff view, since this parent may not have a diff |
| 182 | // for the path in question. |
| Dave Borowitz | dd3c3d9 | 2013-03-11 16:38:41 -0700 | [diff] [blame] | 183 | GitilesView.Builder diff = GitilesView.diff().copyFrom(view).setPathPart(""); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 184 | String parentName; |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 185 | if (parents.size() == 1) { |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 186 | parentName = view.getRevision().getName() + "^"; |
| 187 | } else { |
| Matthias Sohn | 0f85ecb | 2023-09-30 22:56:36 +0200 | [diff] [blame] | 188 | parentName = view.getRevision().getName() + "^" + i++; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 189 | } |
| Dave Borowitz | 8d11fb7 | 2014-09-23 10:27:31 -0700 | [diff] [blame] | 190 | diff.setOldRevision(parentName, parent); |
| 191 | |
| Dave Borowitz | f03fcea | 2014-04-21 17:20:33 -0700 | [diff] [blame] | 192 | Map<String, String> e = Maps.newHashMapWithExpectedSize(4); |
| 193 | e.put("sha", name); |
| Han-Wen Nienhuys | c0200f6 | 2016-05-02 17:34:51 +0200 | [diff] [blame] | 194 | e.put("url", GitilesView.revision().copyFrom(view).setRevision(parentName, parent).toUrl()); |
| Dave Borowitz | 8d11fb7 | 2014-09-23 10:27:31 -0700 | [diff] [blame] | 195 | e.put("diffUrl", diff.toUrl()); |
| Dave Borowitz | f03fcea | 2014-04-21 17:20:33 -0700 | [diff] [blame] | 196 | if (fs.contains(Field.PARENT_BLAME_URL)) { |
| 197 | // Assumes caller has ensured path is a file. |
| Han-Wen Nienhuys | c0200f6 | 2016-05-02 17:34:51 +0200 | [diff] [blame] | 198 | e.put( |
| 199 | "blameUrl", |
| 200 | GitilesView.blame() |
| 201 | .copyFrom(view) |
| 202 | .setRevision(Revision.peeled(parentName, parent)) |
| 203 | .toUrl()); |
| Dave Borowitz | f03fcea | 2014-04-21 17:20:33 -0700 | [diff] [blame] | 204 | } |
| 205 | result.add(e); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 206 | } |
| 207 | return result; |
| 208 | } |
| 209 | |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 210 | private static Object toSoyData(GitilesView view, DiffList dl) { |
| 211 | if (dl.oldRevision == null) { |
| 212 | return NullData.INSTANCE; |
| 213 | } |
| Han-Wen Nienhuys | c0200f6 | 2016-05-02 17:34:51 +0200 | [diff] [blame] | 214 | GitilesView.Builder diffUrl = |
| 215 | GitilesView.diff() |
| 216 | .copyFrom(view) |
| 217 | .setOldRevision(dl.oldRevision) |
| 218 | .setRevision(dl.revision) |
| 219 | .setPathPart(""); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 220 | |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 221 | List<Object> result = Lists.newArrayListWithCapacity(dl.entries.size()); |
| 222 | for (DiffEntry e : dl.entries) { |
| 223 | Map<String, Object> entry = Maps.newHashMapWithExpectedSize(5); |
| 224 | ChangeType type = e.getChangeType(); |
| 225 | if (type != DELETE) { |
| 226 | entry.put("path", e.getNewPath()); |
| Han-Wen Nienhuys | c0200f6 | 2016-05-02 17:34:51 +0200 | [diff] [blame] | 227 | entry.put( |
| 228 | "url", |
| 229 | GitilesView.path() |
| 230 | .copyFrom(view) |
| 231 | .setRevision(dl.revision) |
| 232 | .setPathPart(e.getNewPath()) |
| 233 | .toUrl()); |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 234 | } else { |
| 235 | entry.put("path", e.getOldPath()); |
| Han-Wen Nienhuys | c0200f6 | 2016-05-02 17:34:51 +0200 | [diff] [blame] | 236 | entry.put( |
| 237 | "url", |
| 238 | GitilesView.path() |
| 239 | .copyFrom(view) |
| 240 | .setRevision(dl.oldRevision) |
| 241 | .setPathPart(e.getOldPath()) |
| 242 | .toUrl()); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 243 | } |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 244 | entry.put("diffUrl", diffUrl.setAnchor("F" + result.size()).toUrl()); |
| 245 | entry.put("changeType", e.getChangeType().toString()); |
| 246 | if (type == COPY || type == RENAME) { |
| 247 | entry.put("oldPath", e.getOldPath()); |
| 248 | } |
| 249 | result.add(entry); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 250 | } |
| Dave Borowitz | 0155127 | 2014-03-16 13:43:16 -0700 | [diff] [blame] | 251 | return result; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 252 | } |
| 253 | |
| Han-Wen Nienhuys | c0200f6 | 2016-05-02 17:34:51 +0200 | [diff] [blame] | 254 | private static List<Map<String, String>> toSoyData( |
| 255 | GitilesView view, List<Ref> refs, String prefix) { |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 256 | List<Map<String, String>> result = Lists.newArrayListWithCapacity(refs.size()); |
| 257 | for (Ref ref : refs) { |
| 258 | if (ref.getName().startsWith(prefix)) { |
| Han-Wen Nienhuys | c0200f6 | 2016-05-02 17:34:51 +0200 | [diff] [blame] | 259 | result.add( |
| 260 | ImmutableMap.of( |
| 261 | "name", ref.getName().substring(prefix.length()), |
| 262 | "url", |
| 263 | GitilesView.revision() |
| 264 | .copyFrom(view) |
| 265 | .setRevision(Revision.unpeeled(ref.getName(), ref.getObjectId())) |
| 266 | .toUrl())); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 267 | } |
| 268 | } |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 269 | return result; |
| 270 | } |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 271 | } |