@@ -326,15 +326,8 @@ void checkout(Git git, Repository gitRepo, String branchName) throws Exception {
326326 .pull ()
327327 .setCredentialsProvider (credentials )
328328 .call ();
329- CheckoutCommand cmd = git
330- .checkout ();
331- Ref ref = gitRepo .exactRef ("refs/heads/" + bn );
332- if (ref == null ) {
333- cmd = cmd
334- .setCreateBranch (true )
335- .setStartPoint ("origin/" + bn );
336- }
337- cmd
329+ git
330+ .checkout ()
338331 .setName (bn )
339332 .call ();
340333 }
@@ -688,18 +681,22 @@ public List<VCSTag> getTags() {
688681 } catch (Exception e ) {
689682 throw new RuntimeException (e );
690683 }
691-
692684 }
693685
694686 List <Ref > getTagRefs () throws Exception {
695- return new ArrayList <>(Git
696- .lsRemoteRepository ()
697- .setTags (true )
698- .setHeads (false )
699- .setRemote (repo .getRepoUrl ())
700- .setCredentialsProvider (credentials )
701- .call ());
687+ try (IVCSLockedWorkingCopy wc = repo .getVCSLockedWorkingCopy ();
688+ Git git = getLocalGit (wc );
689+ Repository gitRepo = git .getRepository ()) {
690+
691+ checkout (git , gitRepo , MASTER_BRANCH_NAME );
692+
693+ List <Ref > refs = git
694+ .tagList ()
695+ .call ();
696+
697+ return refs ;
702698 }
699+ }
703700
704701 @ Override
705702 public VCSTag getLastTag () {
@@ -719,11 +716,12 @@ public VCSTag getLastTag() {
719716
720717 Collections .sort (tagRefs , new Comparator <Ref >() {
721718 public int compare (Ref o1 , Ref o2 ) {
722- try {
719+ try (Repository gitRepo = git .getRepository ();
720+ RevWalk rw = new RevWalk (gitRepo )) { // for exception rethrow test only
723721 Date d1 = rw .parseTag (o1 .getObjectId ()).getTaggerIdent ().getWhen ();
724722 Date d2 = rw .parseTag (o2 .getObjectId ()).getTaggerIdent ().getWhen ();
725723 return d1 .compareTo (d2 );
726- } catch (IOException e ) {
724+ } catch (Exception e ) {
727725 throw new RuntimeException (e );
728726 }
729727 }
@@ -757,8 +755,8 @@ public void removeTag(String tagName) {
757755 .tagDelete ()
758756 .setTags (tagName )
759757 .call ();
760-
761- push (git , null );
758+
759+ push (git , new RefSpec ( ":refs/tags/" + tagName ) );
762760
763761 } catch (GitAPIException e ) {
764762 throw new EVCSException (e );
0 commit comments