mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 14:35:45 +01:00
added blame support to client api
This commit is contained in:
@@ -33,6 +33,10 @@
|
||||
|
||||
package sonia.scm.client;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.repository.BlameLine;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -48,6 +52,17 @@ import java.util.List;
|
||||
public interface ClientRepositoryBrowser
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param revision
|
||||
* @param path
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<BlameLine> getBlameLines(String revision, String path);
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
@@ -35,6 +35,7 @@ package sonia.scm.client;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.repository.BlameLine;
|
||||
import sonia.scm.repository.FileObject;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
@@ -70,6 +71,17 @@ public class FileObjectWrapper
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<BlameLine> getBlameLines()
|
||||
{
|
||||
return repositoryBrowser.getBlameLines(revision, getPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
@@ -79,6 +79,9 @@ public class ScmUrlProvider
|
||||
/** Field description */
|
||||
public static final String URLPART_USERS = "users";
|
||||
|
||||
/** Field description */
|
||||
public static final String URLPATTERN_BLAME = "repositories/{0}/blame";
|
||||
|
||||
/** Field description */
|
||||
public static final String URLPATTERN_BROWSE = "repositories/{0}/browse";
|
||||
|
||||
@@ -153,6 +156,24 @@ public class ScmUrlProvider
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repositoryId
|
||||
* @param path
|
||||
* @param revision
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getBlameUrl(String repositoryId, String path, String revision)
|
||||
{
|
||||
String url = MessageFormat.format(getResourceUrl(URLPATTERN_BLAME),
|
||||
repositoryId);
|
||||
|
||||
return appendParameter(url, path, revision);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -215,20 +236,8 @@ public class ScmUrlProvider
|
||||
{
|
||||
String url = MessageFormat.format(getResourceUrl(URLPATTERN_BROWSE),
|
||||
repositoryId);
|
||||
String s = "?";
|
||||
|
||||
if (Util.isNotEmpty(path))
|
||||
{
|
||||
url = url.concat(s).concat("path=").concat(path);
|
||||
s = "&";
|
||||
}
|
||||
|
||||
if (Util.isNotEmpty(revision))
|
||||
{
|
||||
url = url.concat(s).concat("revision=").concat(revision);
|
||||
}
|
||||
|
||||
return url;
|
||||
return appendParameter(url, path, revision);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -391,6 +400,36 @@ public class ScmUrlProvider
|
||||
this.extension = extension;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param url
|
||||
* @param path
|
||||
* @param revision
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String appendParameter(String url, String path, String revision)
|
||||
{
|
||||
String s = "?";
|
||||
|
||||
if (Util.isNotEmpty(path))
|
||||
{
|
||||
url = url.concat(s).concat("path=").concat(path);
|
||||
s = "&";
|
||||
}
|
||||
|
||||
if (Util.isNotEmpty(revision))
|
||||
{
|
||||
url = url.concat(s).concat("revision=").concat(revision);
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
|
||||
Reference in New Issue
Block a user