cleanup and update tests

This commit is contained in:
Konstantin Schaper
2020-08-25 18:08:31 +02:00
parent 6d409c65c0
commit 36231d077a
7 changed files with 91 additions and 32 deletions

View File

@@ -392,27 +392,39 @@ public final class GitUtil
/**
* Method description
*
* @param repository
* @param ref
* @return
* @throws IOException
* @since 2.5.0
*/
public static Long getTagTime(org.eclipse.jgit.lib.Repository repository, Ref ref) throws IOException {
try (RevWalk walk = new RevWalk(repository)) {
return GitUtil.getTagTime(repository, walk, ref);
}
}
/**
* Method description
*
* @param repository
* @param revWalk
* @param ref
*
* @return
*
* @throws IOException
*
* @since 2.5.0
*/
public static Long getTagTime(org.eclipse.jgit.lib.Repository repository,
RevWalk revWalk, Ref ref)
throws IOException
{
RevWalk revWalk, Ref ref)
throws IOException {
if (ref == null) {
return null;
}
ObjectId id = ref.getObjectId();
if (id != null)
{
if (revWalk == null)
{
if (id != null) {
if (revWalk == null) {
revWalk = new RevWalk(repository);
}

View File

@@ -68,8 +68,8 @@ public class GitHookTagProvider implements HookTagProvider {
LOG.debug("received ref name {} is not a tag", refName);
} else {
Long tagTime = null;
try (RevWalk walk = new RevWalk(repository)) {
tagTime = GitUtil.getTagTime(repository, walk, rc.getRef());
try {
tagTime = GitUtil.getTagTime(repository, rc.getRef());
} catch (IOException e) {
LOG.error("Could not read tag time", e);
}