diff options
author | Gerard Smyth <gerard.smyth@gmail.com> | 2014-04-01 12:29:01 +0100 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-05-08 13:09:30 -0400 |
commit | f76fee63ed9cb3a30d3c0c092d860b1cb93a481b (patch) | |
tree | 10177da656f10daae98dc0ba627c702bbf050438 /src/main/java/com/gitblit/utils/JGitUtils.java | |
parent | d99277724206102f25e7c5c569d2e7fdc891e4a0 (diff) | |
download | gitblit-f76fee63ed9cb3a30d3c0c092d860b1cb93a481b.tar.gz gitblit-f76fee63ed9cb3a30d3c0c092d860b1cb93a481b.zip |
Updated the SyndicationServlet to provide an additional option to return details of the tags in the repository instead of the commits.
This uses a new 'ot' request parameter to indicate the object type of the content to return, which can be ither TAG or COMMIT.
If this is not provided, then COMMIT is assumed to maintain backwards compatability.
If tags are returned, then the paging parameters, 'l' and 'pg' are still supported, but searching options are currently ignored.
Diffstat (limited to 'src/main/java/com/gitblit/utils/JGitUtils.java')
-rw-r--r-- | src/main/java/com/gitblit/utils/JGitUtils.java | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/src/main/java/com/gitblit/utils/JGitUtils.java b/src/main/java/com/gitblit/utils/JGitUtils.java index 190872a7..da51ea98 100644 --- a/src/main/java/com/gitblit/utils/JGitUtils.java +++ b/src/main/java/com/gitblit/utils/JGitUtils.java @@ -1668,6 +1668,24 @@ public class JGitUtils { }
/**
+ * Returns the list of tags in the repository. If repository does not exist
+ * or is empty, an empty list is returned.
+ *
+ * @param repository
+ * @param fullName
+ * if true, /refs/tags/yadayadayada is returned. If false,
+ * yadayadayada is returned.
+ * @param maxCount
+ * if < 0, all tags are returned
+ * @param offset
+ * if maxCount provided sets the starting point of the records to return
+ * @return list of tags
+ */
+ public static List<RefModel> getTags(Repository repository, boolean fullName, int maxCount, int offset) {
+ return getRefs(repository, Constants.R_TAGS, fullName, maxCount, offset);
+ }
+
+ /**
* Returns the list of local branches in the repository. If repository does
* not exist or is empty, an empty list is returned.
*
@@ -1748,6 +1766,27 @@ public class JGitUtils { */
private static List<RefModel> getRefs(Repository repository, String refs, boolean fullName,
int maxCount) {
+ return getRefs(repository, refs, fullName, maxCount, 0);
+ }
+
+ /**
+ * Returns a list of references in the repository matching "refs". If the
+ * repository is null or empty, an empty list is returned.
+ *
+ * @param repository
+ * @param refs
+ * if unspecified, all refs are returned
+ * @param fullName
+ * if true, /refs/something/yadayadayada is returned. If false,
+ * yadayadayada is returned.
+ * @param maxCount
+ * if < 0, all references are returned
+ * @param offset
+ * if maxCount provided sets the starting point of the records to return
+ * @return list of references
+ */
+ private static List<RefModel> getRefs(Repository repository, String refs, boolean fullName,
+ int maxCount, int offset) {
List<RefModel> list = new ArrayList<RefModel>();
if (maxCount == 0) {
return list;
@@ -1771,7 +1810,14 @@ public class JGitUtils { Collections.sort(list);
Collections.reverse(list);
if (maxCount > 0 && list.size() > maxCount) {
- list = new ArrayList<RefModel>(list.subList(0, maxCount));
+ if (offset < 0) {
+ offset = 0;
+ }
+ int endIndex = offset + maxCount;
+ if (endIndex > list.size()) {
+ endIndex = list.size();
+ }
+ list = new ArrayList<RefModel>(list.subList(offset, endIndex));
}
} catch (IOException e) {
error(e, repository, "{0} failed to retrieve {1}", refs);
|