| 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 | c410f96 | 2014-09-23 10:49:26 -0700 | [diff] [blame] | 17 | import static com.google.common.base.MoreObjects.toStringHelper; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 18 | import static com.google.common.base.Preconditions.checkNotNull; |
| Dave Borowitz | c410f96 | 2014-09-23 10:49:26 -0700 | [diff] [blame] | 19 | import static java.util.Objects.hash; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 20 | |
| Dave Borowitz | fe8fdab | 2014-11-04 16:19:33 -0800 | [diff] [blame] | 21 | import com.google.common.annotations.VisibleForTesting; |
| 22 | import com.google.common.base.CharMatcher; |
| Dave Borowitz | fe8fdab | 2014-11-04 16:19:33 -0800 | [diff] [blame] | 23 | import com.google.common.base.Splitter; |
| Ronald Bhuleskar | 999a71d | 2021-11-19 15:24:51 -0800 | [diff] [blame] | 24 | import com.google.common.base.Strings; |
| Dave Borowitz | 3b744b1 | 2016-08-19 16:11:10 -0400 | [diff] [blame] | 25 | import java.io.IOException; |
| 26 | import java.util.Objects; |
| Ronald Bhuleskar | 999a71d | 2021-11-19 15:24:51 -0800 | [diff] [blame] | 27 | import java.util.Optional; |
| 28 | import java.util.regex.Matcher; |
| 29 | import java.util.regex.Pattern; |
| Matthias Sohn | c156c96 | 2023-09-30 22:15:23 +0200 | [diff] [blame] | 30 | import javax.annotation.Nullable; |
| Dave Borowitz | 93c1fca | 2013-09-25 16:37:43 -0700 | [diff] [blame] | 31 | import org.eclipse.jgit.errors.AmbiguousObjectException; |
| Dave Borowitz | 48ca670 | 2013-04-09 11:52:41 -0700 | [diff] [blame] | 32 | import org.eclipse.jgit.errors.MissingObjectException; |
| Dave Borowitz | 5f7e8b7 | 2013-01-07 09:31:41 -0800 | [diff] [blame] | 33 | import org.eclipse.jgit.errors.RevisionSyntaxException; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 34 | import org.eclipse.jgit.lib.ObjectId; |
| 35 | import org.eclipse.jgit.lib.Repository; |
| 36 | import org.eclipse.jgit.revwalk.RevCommit; |
| Dave Borowitz | 48ca670 | 2013-04-09 11:52:41 -0700 | [diff] [blame] | 37 | import org.eclipse.jgit.revwalk.RevObject; |
| 38 | import org.eclipse.jgit.revwalk.RevTag; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 39 | import org.eclipse.jgit.revwalk.RevWalk; |
| 40 | |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 41 | /** Object to parse revisions out of Gitiles paths. */ |
| 42 | class RevisionParser { |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 43 | private static final Splitter OPERATOR_SPLITTER = Splitter.on(CharMatcher.anyOf("^~")); |
| 44 | |
| Ronald Bhuleskar | 999a71d | 2021-11-19 15:24:51 -0800 | [diff] [blame] | 45 | // The ref name part of a revision expression ends at the first |
| 46 | // appearance of ^, ~, :, or @{ (see git-check-ref-format(1)). |
| 47 | private static final Pattern END_OF_REF = Pattern.compile("[\\^~:]|@\\{"); |
| 48 | |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 49 | static class Result { |
| 50 | private final Revision revision; |
| 51 | private final Revision oldRevision; |
| Dave Borowitz | 06b88d2 | 2013-06-19 15:19:14 -0700 | [diff] [blame] | 52 | private final String path; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 53 | |
| 54 | @VisibleForTesting |
| 55 | Result(Revision revision) { |
| Dave Borowitz | 06b88d2 | 2013-06-19 15:19:14 -0700 | [diff] [blame] | 56 | this(revision, null, ""); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | @VisibleForTesting |
| Dave Borowitz | 06b88d2 | 2013-06-19 15:19:14 -0700 | [diff] [blame] | 60 | Result(Revision revision, Revision oldRevision, String path) { |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 61 | this.revision = revision; |
| 62 | this.oldRevision = oldRevision; |
| Dave Borowitz | 06b88d2 | 2013-06-19 15:19:14 -0700 | [diff] [blame] | 63 | this.path = path; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | public Revision getRevision() { |
| 67 | return revision; |
| 68 | } |
| 69 | |
| 70 | public Revision getOldRevision() { |
| 71 | return oldRevision; |
| 72 | } |
| 73 | |
| Dave Borowitz | 06b88d2 | 2013-06-19 15:19:14 -0700 | [diff] [blame] | 74 | public String getPath() { |
| 75 | return path; |
| 76 | } |
| 77 | |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 78 | @Override |
| 79 | public boolean equals(Object o) { |
| 80 | if (o instanceof Result) { |
| 81 | Result r = (Result) o; |
| Dave Borowitz | c410f96 | 2014-09-23 10:49:26 -0700 | [diff] [blame] | 82 | return Objects.equals(revision, r.revision) |
| 83 | && Objects.equals(oldRevision, r.oldRevision) |
| 84 | && Objects.equals(path, r.path); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 85 | } |
| 86 | return false; |
| 87 | } |
| 88 | |
| 89 | @Override |
| 90 | public int hashCode() { |
| Dave Borowitz | c410f96 | 2014-09-23 10:49:26 -0700 | [diff] [blame] | 91 | return hash(revision, oldRevision, path); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | @Override |
| 95 | public String toString() { |
| Dave Borowitz | c410f96 | 2014-09-23 10:49:26 -0700 | [diff] [blame] | 96 | return toStringHelper(this) |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 97 | .omitNullValues() |
| Dave Borowitz | 06b88d2 | 2013-06-19 15:19:14 -0700 | [diff] [blame] | 98 | .add("revision", revision.getName()) |
| 99 | .add("oldRevision", oldRevision != null ? oldRevision.getName() : null) |
| 100 | .add("path", path) |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 101 | .toString(); |
| 102 | } |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | private final Repository repo; |
| 106 | private final GitilesAccess access; |
| 107 | private final VisibilityCache cache; |
| Ronald Bhuleskar | 999a71d | 2021-11-19 15:24:51 -0800 | [diff] [blame] | 108 | private final BranchRedirect branchRedirect; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 109 | |
| Ronald Bhuleskar | 999a71d | 2021-11-19 15:24:51 -0800 | [diff] [blame] | 110 | RevisionParser( |
| 111 | Repository repo, GitilesAccess access, VisibilityCache cache, BranchRedirect branchRedirect) { |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 112 | this.repo = checkNotNull(repo, "repo"); |
| 113 | this.access = checkNotNull(access, "access"); |
| 114 | this.cache = checkNotNull(cache, "cache"); |
| Ronald Bhuleskar | 999a71d | 2021-11-19 15:24:51 -0800 | [diff] [blame] | 115 | this.branchRedirect = checkNotNull(branchRedirect, "branchRedirect"); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 116 | } |
| 117 | |
| Matthias Sohn | c156c96 | 2023-09-30 22:15:23 +0200 | [diff] [blame] | 118 | @Nullable |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 119 | Result parse(String path) throws IOException { |
| Dave Borowitz | 06b88d2 | 2013-06-19 15:19:14 -0700 | [diff] [blame] | 120 | if (path.startsWith("/")) { |
| 121 | path = path.substring(1); |
| 122 | } |
| Ronald Bhuleskar | 999a71d | 2021-11-19 15:24:51 -0800 | [diff] [blame] | 123 | if (Strings.isNullOrEmpty(path)) { |
| 124 | return null; |
| 125 | } |
| Shawn Pearce | b5ad0a0 | 2015-05-24 20:33:17 -0700 | [diff] [blame] | 126 | try (RevWalk walk = new RevWalk(repo)) { |
| Jonathan Nieder | c63c059 | 2019-03-07 14:40:49 -0800 | [diff] [blame] | 127 | walk.setRetainBody(false); |
| 128 | |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 129 | Revision oldRevision = null; |
| Ronald Bhuleskar | 999a71d | 2021-11-19 15:24:51 -0800 | [diff] [blame] | 130 | Revision oldRevisionRedirected = null; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 131 | |
| 132 | StringBuilder b = new StringBuilder(); |
| 133 | boolean first = true; |
| Dave Borowitz | cfc1c53 | 2015-02-18 13:41:19 -0800 | [diff] [blame] | 134 | for (String part : PathUtil.SPLITTER.split(path)) { |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 135 | if (part.isEmpty()) { |
| 136 | return null; // No valid revision contains empty segments. |
| 137 | } |
| 138 | if (!first) { |
| 139 | b.append('/'); |
| 140 | } |
| 141 | |
| 142 | if (oldRevision == null) { |
| 143 | int dots = part.indexOf(".."); |
| 144 | int firstParent = part.indexOf("^!"); |
| 145 | if (dots == 0 || firstParent == 0) { |
| 146 | return null; |
| 147 | } else if (dots > 0) { |
| Dave Borowitz | 2705893 | 2014-12-03 15:44:46 -0800 | [diff] [blame] | 148 | b.append(part, 0, dots); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 149 | String oldName = b.toString(); |
| Ronald Bhuleskar | 999a71d | 2021-11-19 15:24:51 -0800 | [diff] [blame] | 150 | String oldNameRedirect = getRedirectFor(oldName); |
| 151 | |
| 152 | if (!isValidRevision(oldNameRedirect)) { |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 153 | return null; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 154 | } |
| Ronald Bhuleskar | 999a71d | 2021-11-19 15:24:51 -0800 | [diff] [blame] | 155 | RevObject old = resolve(oldNameRedirect, walk); |
| David Pursehouse | b3b630f | 2016-06-15 21:51:18 +0900 | [diff] [blame] | 156 | if (old == null) { |
| 157 | return null; |
| 158 | } |
| Ronald Bhuleskar | 999a71d | 2021-11-19 15:24:51 -0800 | [diff] [blame] | 159 | /* |
| 160 | * Retain oldRevision with the old name (non-redirected-path) since it is used in |
| 161 | * determining the Revision path (start index of the path from the name). |
| 162 | * For example: For a master -> main redirect, |
| 163 | * original path: /master/index.c is updated to /main/index.c |
| 164 | * To parse the ref/path to build Revision object we look at the original path. |
| 165 | */ |
| David Pursehouse | b3b630f | 2016-06-15 21:51:18 +0900 | [diff] [blame] | 166 | oldRevision = Revision.peel(oldName, old, walk); |
| Ronald Bhuleskar | 999a71d | 2021-11-19 15:24:51 -0800 | [diff] [blame] | 167 | oldRevisionRedirected = Revision.peel(oldNameRedirect, old, walk); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 168 | part = part.substring(dots + 2); |
| 169 | b = new StringBuilder(); |
| 170 | } else if (firstParent > 0) { |
| 171 | if (firstParent != part.length() - 2) { |
| 172 | return null; |
| 173 | } |
| Dave Borowitz | 2705893 | 2014-12-03 15:44:46 -0800 | [diff] [blame] | 174 | b.append(part, 0, part.length() - 2); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 175 | String name = b.toString(); |
| 176 | if (!isValidRevision(name)) { |
| 177 | return null; |
| 178 | } |
| Ronald Bhuleskar | 999a71d | 2021-11-19 15:24:51 -0800 | [diff] [blame] | 179 | |
| 180 | String nameRedirected = getRedirectFor(name); |
| 181 | RevObject obj = resolve(nameRedirected, walk); |
| Dave Borowitz | 48ca670 | 2013-04-09 11:52:41 -0700 | [diff] [blame] | 182 | if (obj == null) { |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 183 | return null; |
| 184 | } |
| Dave Borowitz | 48ca670 | 2013-04-09 11:52:41 -0700 | [diff] [blame] | 185 | while (obj instanceof RevTag) { |
| 186 | obj = ((RevTag) obj).getObject(); |
| 187 | walk.parseHeaders(obj); |
| 188 | } |
| 189 | if (!(obj instanceof RevCommit)) { |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 190 | return null; // Not a commit, ^! is invalid. |
| 191 | } |
| Dave Borowitz | 48ca670 | 2013-04-09 11:52:41 -0700 | [diff] [blame] | 192 | RevCommit c = (RevCommit) obj; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 193 | if (c.getParentCount() > 0) { |
| Ronald Bhuleskar | 999a71d | 2021-11-19 15:24:51 -0800 | [diff] [blame] | 194 | oldRevisionRedirected = Revision.peeled(nameRedirected + "^", c.getParent(0)); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 195 | } else { |
| Ronald Bhuleskar | 999a71d | 2021-11-19 15:24:51 -0800 | [diff] [blame] | 196 | oldRevisionRedirected = Revision.NULL; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 197 | } |
| Han-Wen Nienhuys | c0200f6 | 2016-05-02 17:34:51 +0200 | [diff] [blame] | 198 | Result result = |
| 199 | new Result( |
| Ronald Bhuleskar | 999a71d | 2021-11-19 15:24:51 -0800 | [diff] [blame] | 200 | Revision.peeled(nameRedirected, c), |
| 201 | oldRevisionRedirected, |
| 202 | path.substring(name.length() + 2)); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 203 | return isVisible(walk, result) ? result : null; |
| 204 | } |
| 205 | } |
| 206 | b.append(part); |
| 207 | |
| 208 | String name = b.toString(); |
| 209 | if (!isValidRevision(name)) { |
| 210 | return null; |
| 211 | } |
| Ronald Bhuleskar | 999a71d | 2021-11-19 15:24:51 -0800 | [diff] [blame] | 212 | String nameRedirected = getRedirectFor(name); |
| 213 | |
| 214 | RevObject obj = resolve(nameRedirected, walk); |
| Dave Borowitz | 48ca670 | 2013-04-09 11:52:41 -0700 | [diff] [blame] | 215 | if (obj != null) { |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 216 | int pathStart; |
| 217 | if (oldRevision == null) { |
| 218 | pathStart = name.length(); // foo |
| 219 | } else { |
| 220 | // foo..bar (foo may be empty) |
| 221 | pathStart = oldRevision.getName().length() + 2 + name.length(); |
| 222 | } |
| Dave Borowitz | e360d5c | 2015-09-16 16:53:30 -0400 | [diff] [blame] | 223 | Result result = |
| Ronald Bhuleskar | 999a71d | 2021-11-19 15:24:51 -0800 | [diff] [blame] | 224 | new Result( |
| 225 | Revision.peel(nameRedirected, obj, walk), |
| 226 | oldRevisionRedirected, |
| 227 | path.substring(pathStart)); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 228 | return isVisible(walk, result) ? result : null; |
| 229 | } |
| 230 | first = false; |
| 231 | } |
| 232 | return null; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 233 | } |
| 234 | } |
| 235 | |
| Matthias Sohn | c156c96 | 2023-09-30 22:15:23 +0200 | [diff] [blame] | 236 | private @Nullable RevObject resolve(String name, RevWalk walk) throws IOException { |
| Dave Borowitz | 5f7e8b7 | 2013-01-07 09:31:41 -0800 | [diff] [blame] | 237 | try { |
| Dave Borowitz | 48ca670 | 2013-04-09 11:52:41 -0700 | [diff] [blame] | 238 | ObjectId id = repo.resolve(name); |
| 239 | return id != null ? walk.parseAny(id) : null; |
| Dave Borowitz | 93c1fca | 2013-09-25 16:37:43 -0700 | [diff] [blame] | 240 | } catch (AmbiguousObjectException e) { |
| 241 | // TODO(dborowitz): Render a helpful disambiguation page. |
| 242 | return null; |
| Dave Borowitz | 2705893 | 2014-12-03 15:44:46 -0800 | [diff] [blame] | 243 | } catch (RevisionSyntaxException | MissingObjectException e) { |
| Dave Borowitz | 48ca670 | 2013-04-09 11:52:41 -0700 | [diff] [blame] | 244 | return null; |
| Dave Borowitz | 5f7e8b7 | 2013-01-07 09:31:41 -0800 | [diff] [blame] | 245 | } |
| 246 | } |
| 247 | |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 248 | private static boolean isValidRevision(String revision) { |
| 249 | // Disallow some uncommon but valid revision expressions that either we |
| 250 | // don't support or we represent differently in our URLs. |
| Jonathan Nieder | 4a7dac0 | 2019-07-01 16:15:03 -0700 | [diff] [blame] | 251 | return !revision.contains(":") |
| 252 | && !revision.contains("^{") |
| 253 | && !revision.contains("@{") |
| 254 | && !revision.equals("@"); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | private boolean isVisible(RevWalk walk, Result result) throws IOException { |
| 258 | String maybeRef = OPERATOR_SPLITTER.split(result.getRevision().getName()).iterator().next(); |
| Dave Borowitz | 14cad73 | 2016-05-26 17:34:19 -0400 | [diff] [blame] | 259 | if (repo.findRef(maybeRef) != null) { |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 260 | // Name contains a visible ref; skip expensive reachability check. |
| 261 | return true; |
| 262 | } |
| Dave Borowitz | df363d2 | 2013-06-10 11:18:04 -0700 | [diff] [blame] | 263 | ObjectId id = result.getRevision().getId(); |
| 264 | if (!cache.isVisible(repo, walk, access, id)) { |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 265 | return false; |
| 266 | } |
| David Pursehouse | c53de2b | 2019-06-01 15:27:25 +0900 | [diff] [blame] | 267 | if (result.getOldRevision() != null && !Revision.isNull(result.getOldRevision())) { |
| Dave Borowitz | df363d2 | 2013-06-10 11:18:04 -0700 | [diff] [blame] | 268 | return cache.isVisible(repo, walk, access, result.getOldRevision().getId(), id); |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 269 | } |
| David Pursehouse | b3b630f | 2016-06-15 21:51:18 +0900 | [diff] [blame] | 270 | return true; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 271 | } |
| Ronald Bhuleskar | 999a71d | 2021-11-19 15:24:51 -0800 | [diff] [blame] | 272 | |
| 273 | /** |
| 274 | * It replaces the ref in the revision expression to the redirected refName, without changing the |
| 275 | * behavior of the expression. |
| 276 | * |
| 277 | * <p>For eg: branch redirect {master -> main} would yield {master -> main}, {refs/heads/master^ |
| 278 | * -> refs/heads/main^}, {refs/heads/master^ -> refs/heads/main^}. It does expand to a full |
| 279 | * refName even for shorter refNames. |
| 280 | */ |
| 281 | private String getRedirectFor(String revisionExpression) { |
| 282 | String refName = refPart(revisionExpression); |
| 283 | Optional<String> redirect = branchRedirect.getRedirectBranch(repo, refName); |
| 284 | if (redirect.isPresent()) { |
| 285 | return redirect.get() + revisionExpression.substring(refName.length()); |
| 286 | } |
| 287 | return revisionExpression; |
| 288 | } |
| 289 | |
| 290 | private static String refPart(String revisionExpression) { |
| 291 | Matcher m = END_OF_REF.matcher(revisionExpression); |
| 292 | if (!m.find()) { // no terminator -> the whole string is a ref name. |
| 293 | return revisionExpression; |
| 294 | } |
| 295 | return revisionExpression.substring(0, m.start()); |
| 296 | } |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 297 | } |