SVNKit: how to get the version number from the working directory

I would like to implement a method that can get the svn version number from the path where the SVN repository was uploaded. The method declaration will look something like this:

long getRevisionNumber(String localPath) { ... }

I am trying to use SVNKit for this, but it seems to require an SVN URL. Is there a way to start from a local path?

+3
source share
2 answers
public static long getRevisionNumber(String localPath) throws SVNException {
    final SVNStatus status = SVNClientManager.newInstance().getStatusClient().doStatus(new File(localPath), false);
    return status != null ? status.getRevision().getNumber() : -1;
}
+6
source

You can also use the method getCommittedRevision(). It returns a revision for a specific file when it was the last.

clientManager.getStatusClient().doStatus(destination, false).getCommittedRevision().getNumber();
0
source

Source: https://habr.com/ru/post/1743014/


All Articles