mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 23:15:43 +01:00
initial implementation
This commit is contained in:
@@ -78,6 +78,7 @@ public class GitTagCommand implements TagCommand
|
||||
String revision = request.getRevision();
|
||||
|
||||
RevObject revObject = null;
|
||||
Long tagTime = null;
|
||||
|
||||
if (!Strings.isNullOrEmpty(revision))
|
||||
{
|
||||
@@ -88,6 +89,7 @@ public class GitTagCommand implements TagCommand
|
||||
{
|
||||
walk = new RevWalk(git.getRepository());
|
||||
revObject = walk.parseAny(id);
|
||||
tagTime = GitUtil.getTagTime(git.getRepository(), walk, GitUtil.getRefForCommit(git.getRepository(), id));
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -110,9 +112,9 @@ public class GitTagCommand implements TagCommand
|
||||
}
|
||||
|
||||
if (ref.isPeeled()) {
|
||||
tag = new Tag(request.getName(), ref.getPeeledObjectId().toString());
|
||||
tag = new Tag(request.getName(), ref.getPeeledObjectId().toString(), tagTime);
|
||||
} else {
|
||||
tag = new Tag(request.getName(), ref.getObjectId().toString());
|
||||
tag = new Tag(request.getName(), ref.getObjectId().toString(), tagTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.github.sdorra.shiro.ShiroRule;
|
||||
import com.github.sdorra.shiro.SubjectAware;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import sonia.scm.repository.Tag;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@SubjectAware(configuration = "classpath:sonia/scm/configuration/shiro.ini", username = "admin", password = "secret")
|
||||
public class GitTagsCommandTest extends AbstractGitCommandTestBase {
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
|
||||
@Rule
|
||||
public BindTransportProtocolRule transportProtocolRule = new BindTransportProtocolRule();
|
||||
|
||||
@Rule
|
||||
public ShiroRule shiro = new ShiroRule();
|
||||
|
||||
@Test
|
||||
public void shouldGetDatesCorrectly() throws IOException {
|
||||
final GitContext gitContext = createContext();
|
||||
final GitTagsCommand tagsCommand = new GitTagsCommand(gitContext);
|
||||
final List<Tag> tags = tagsCommand.getTags();
|
||||
assertThat(tags).hasSize(2);
|
||||
assertThat(tags.get(0).getName()).isEqualTo("1.0.0");
|
||||
assertThat(tags.get(0).getDate()).isEqualTo(1598348105000L); // Annotated - Take tag date
|
||||
assertThat(tags.get(1).getName()).isEqualTo("test-tag");
|
||||
assertThat(tags.get(1).getDate()).isEqualTo(1339416344000L); // Lightweight - Take commit date
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getZippedRepositoryResource() {
|
||||
return "sonia/scm/repository/spi/scm-git-spi-test-tags.zip";
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user