[java-support] branch main updated: Add method for accessing repositories on other branches.

Scott Cantor cantor.2 at osu.edu
Mon Jan 31 13:51:09 UTC 2022


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch main
in repository java-support.

View the commit online:
http://git.shibboleth.net/view/?p=java-support.git;a=commit;h=f51501e3dba7c3b377af43b990b53a5c69a54125

The following commit(s) were added to refs/heads/main by this push:
     new f51501e  Add method for accessing repositories on other branches.
f51501e is described below

commit f51501e3dba7c3b377af43b990b53a5c69a54125
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Jan 31 08:51:04 2022 -0500

    Add method for accessing repositories on other branches.
---
 .../support/test/repository/RepositorySupport.java | 35 ++++++++++++++++------
 1 file changed, 26 insertions(+), 9 deletions(-)

diff --git a/src/test/java/net/shibboleth/utilities/java/support/test/repository/RepositorySupport.java b/src/test/java/net/shibboleth/utilities/java/support/test/repository/RepositorySupport.java
index ef12dad..0c2eee3 100644
--- a/src/test/java/net/shibboleth/utilities/java/support/test/repository/RepositorySupport.java
+++ b/src/test/java/net/shibboleth/utilities/java/support/test/repository/RepositorySupport.java
@@ -19,22 +19,22 @@ package net.shibboleth.utilities.java.support.test.repository;
 
 import javax.annotation.Nonnull;
 
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
 import net.shibboleth.utilities.java.support.logic.Constraint;
 import net.shibboleth.utilities.java.support.primitive.StringSupport;
 
-/**
- * Support class for working with the project version control repository.
- */
+/** Support class for working with the project version control repository. */
 public final class RepositorySupport {
     
     /** Constructor. */
     private RepositorySupport() { } 
     
     /**
-     * Build an HTTPS resource URL for the selected repository name and path.
+     * Build an HTTPS resource URL for the selected repository name and path on the main branch.
      * 
      * @param repoName the repository name.  If Git, do not include the ".git" suffix.
      * @param resourcePath The relative resource path within the repository, e.g. "foo/bar/baz/file.txt"
+     * 
      * @return the HTTPS resource URL
      */
     public static String buildHTTPSResourceURL(@Nonnull final String repoName, @Nonnull final String resourcePath) {
@@ -42,15 +42,33 @@ public final class RepositorySupport {
     }
     
     /**
-     * Build an HTTP/HTTPS resource URL for the selected repository name and path.
+     * Build an HTTP/HTTPS resource URL for the selected repository name and path on the main branch.
      * 
      * @param repoName the repository name.  If Git, do not include a trailing ".git" suffix for bare repos.
      * @param resourcePath The relative resource path within the repository, e.g. "foo/bar/baz/file.txt"
      * @param https if true, use https if possible, otherwise use http
+     * 
      * @return the HTTP(S) resource URL
      */
     public static String buildHTTPResourceURL(@Nonnull final String repoName, @Nonnull final String resourcePath, 
             final boolean https) {
+        return buildHTTPResourceURL(repoName, resourcePath, true, "HEAD");
+    }
+    
+    /**
+     * Build an HTTP/HTTPS resource URL for the selected repository name and path.
+     * 
+     * @param repoName the repository name.  If Git, do not include a trailing ".git" suffix for bare repos.
+     * @param resourcePath The relative resource path within the repository, e.g. "foo/bar/baz/file.txt"
+     * @param https if true, use https if possible, otherwise use http
+     * @param branch code branch
+     * 
+     * @return the HTTP(S) resource URL
+     * 
+     * @since 8.2.0
+     */
+    public static String buildHTTPResourceURL(@Nonnull final String repoName, @Nonnull final String resourcePath, 
+            final boolean https, @Nonnull @NotEmpty final String branch) {
         
         final String repo = Constraint.isNotNull(StringSupport.trimOrNull(repoName), 
                 "Repository name was null or empty");
@@ -62,10 +80,9 @@ public final class RepositorySupport {
         }
         
         if (https) {
-            return String.format("https://test.shibboleth.net/git/view/?p=%s.git&a=blob_plain&f=%s&hb=HEAD", repo, path);
+            return String.format("https://test.shibboleth.net/git/view/?p=%s.git&a=blob_plain&f=%s&hb=%s", repo, path, branch);
         }
-        return String.format("http://git.shibboleth.net/view/?p=%s.git&a=blob_plain&f=%s&hb=HEAD", repo, path);
-        
+        return String.format("http://git.shibboleth.net/view/?p=%s.git&a=blob_plain&f=%s&hb=%s", repo, branch);
     }
 
-}
+}
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list