mirror of
				https://github.com/scm-manager/scm-manager.git
				synced 2025-10-31 18:46:07 +01:00 
			
		
		
		
	remove ref usage and directly use objectId
This commit is contained in:
		| @@ -390,45 +390,27 @@ 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 { | ||||
|   public static Long getTagTime(org.eclipse.jgit.lib.Repository repository, ObjectId objectId) throws IOException { | ||||
|     try (RevWalk walk = new RevWalk(repository)) { | ||||
|       return GitUtil.getTagTime(repository, walk, ref); | ||||
|       return GitUtil.getTagTime(repository, walk, objectId); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * 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) | ||||
|                                 RevWalk revWalk, ObjectId objectId) | ||||
|     throws IOException { | ||||
|     if (ref == null) { | ||||
|       return null; | ||||
|     } | ||||
|  | ||||
|     ObjectId id = ref.getObjectId(); | ||||
|  | ||||
|     if (id != null) { | ||||
|     if (objectId != null) { | ||||
|       if (revWalk == null) { | ||||
|         revWalk = new RevWalk(repository); | ||||
|       } | ||||
|  | ||||
|       final RevObject revObject = revWalk.parseAny(id); | ||||
|       final RevObject revObject = revWalk.parseAny(objectId); | ||||
|       if (revObject instanceof RevTag) { | ||||
|         return ((RevTag) revObject).getTaggerIdent().getWhen().getTime(); | ||||
|       } else if (revObject instanceof RevCommit) { | ||||
|   | ||||
| @@ -26,18 +26,16 @@ package sonia.scm.repository.api; | ||||
|  | ||||
| import com.google.common.base.Strings; | ||||
| import com.google.common.collect.ImmutableList; | ||||
|  | ||||
| import java.io.IOException; | ||||
| import java.util.List; | ||||
|  | ||||
| import org.eclipse.jgit.lib.Repository; | ||||
| import org.eclipse.jgit.revwalk.RevWalk; | ||||
| import org.eclipse.jgit.transport.ReceiveCommand; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import sonia.scm.repository.GitUtil; | ||||
| import sonia.scm.repository.Tag; | ||||
|  | ||||
| import java.io.IOException; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * Git provider implementation of {@link HookTagProvider}. | ||||
|  * | ||||
| @@ -67,20 +65,18 @@ public class GitHookTagProvider implements HookTagProvider { | ||||
|       if (Strings.isNullOrEmpty(tag)) { | ||||
|         LOG.debug("received ref name {} is not a tag", refName); | ||||
|       } else { | ||||
|         Long tagTime = null; | ||||
|         try { | ||||
|           tagTime = GitUtil.getTagTime(repository, rc.getRef()); | ||||
|           if (isCreate(rc)) { | ||||
|             createdTagBuilder.add(createTagFromNewId(rc, tag, GitUtil.getTagTime(repository, rc.getNewId()))); | ||||
|           } else if (isDelete(rc)) { | ||||
|             deletedTagBuilder.add(createTagFromOldId(rc, tag, GitUtil.getTagTime(repository, rc.getOldId()))); | ||||
|           } else if (isUpdate(rc)) { | ||||
|             createdTagBuilder.add(createTagFromNewId(rc, tag, GitUtil.getTagTime(repository, rc.getNewId()))); | ||||
|             deletedTagBuilder.add(createTagFromOldId(rc, tag, GitUtil.getTagTime(repository, rc.getOldId()))); | ||||
|           } | ||||
|         } catch (IOException e) { | ||||
|           LOG.error("Could not read tag time", e); | ||||
|         } | ||||
|         if (isCreate(rc)) { | ||||
|           createdTagBuilder.add(createTagFromNewId(rc, tag, tagTime)); | ||||
|         } else if (isDelete(rc)) { | ||||
|           deletedTagBuilder.add(createTagFromOldId(rc, tag, tagTime)); | ||||
|         } else if (isUpdate(rc)) { | ||||
|           createdTagBuilder.add(createTagFromNewId(rc, tag, tagTime)); | ||||
|           deletedTagBuilder.add(createTagFromOldId(rc, tag, tagTime)); | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -132,7 +132,7 @@ public class GitTagsCommand extends AbstractGitCommand implements TagsCommand { | ||||
|         if (revObject != null) { | ||||
|           String name = GitUtil.getTagName(ref); | ||||
|  | ||||
|           tag = new Tag(name, revObject.getId().name(), GitUtil.getTagTime(repository, revWalk, ref)); | ||||
|           tag = new Tag(name, revObject.getId().name(), GitUtil.getTagTime(repository, revWalk, ref.getObjectId())); | ||||
|         } | ||||
|  | ||||
|       } catch (IOException ex) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user