@Given("^I have a remote tag called \"([^\"]*)\"$") public void i_have_a_remote_tag_called(String expected) throws Throwable { localRepo.geogigCLI.getGeogig(Hints.readWrite()) // .command(TagCreateOp.class) // .setName(expected) // .setMessage("Tagged " + expected) // .setCommitId(ObjectId.NULL) // .call(); }
/** * Executes the tag creation operation. * * @return the created tag * */ @Override protected RevTag _call() throws RuntimeException { checkState(name != null, "tag name was not provided"); final String tagRefPath = Ref.TAGS_PREFIX + name; checkArgument(!command(RefParse.class).setName(tagRefPath).call().isPresent(), "A tag named '" + name + "' already exists."); command(CheckRefFormat.class).setThrowsException(true).setRef(tagRefPath).call(); if (commitId == null) { final Optional<Ref> currHead = command(RefParse.class).setName(Ref.HEAD).call(); Preconditions.checkState(currHead.isPresent(), "Repository has no HEAD, can't create tag"); commitId = currHead.get().getObjectId(); } RevPerson tagger = resolveTagger(); message = message == null ? "" : message; RevTag tag = RevTagBuilder.build(name, commitId, message, tagger); objectDatabase().put(tag); Optional<Ref> branchRef = command(UpdateRef.class).setName(tagRefPath) .setNewValue(tag.getId()).call(); checkState(branchRef.isPresent()); return tag; }
private RevPerson resolveTagger() { final String nameKey = "user.name"; final String emailKey = "user.email"; String taggerName = getClientData(nameKey, String.class) .or(command(ConfigGet.class).setName(nameKey).call()).orNull(); String taggerEmail = getClientData(emailKey, String.class) .or(command(ConfigGet.class).setName(emailKey).call()).orNull(); checkState(taggerName != null, "%s not found in config. Use geogig config [--global] %s <your name> to configure it.", nameKey, nameKey); checkState(taggerEmail != null, "%s not found in config. Use geogig config [--global] %s <your email> to configure it.", emailKey, emailKey); Platform platform = platform(); long taggerTimeStamp = platform.currentTimeMillis(); int taggerTimeZoneOffset = platform.timeZoneOffset(taggerTimeStamp); return RevPerson.builder().build(taggerName, taggerEmail, taggerTimeStamp, taggerTimeZoneOffset); }
private RevPerson resolveTagger() { final String nameKey = "user.name"; final String emailKey = "user.email"; Optional<String> name = command(ConfigGet.class).setName(nameKey).call(); Optional<String> email = command(ConfigGet.class).setName(emailKey).call(); checkState(name.isPresent(), "%s not found in config. Use geogig config [--global] %s <your name> to configure it.", nameKey, nameKey); checkState(email.isPresent(), "%s not found in config. Use geogig config [--global] %s <your email> to configure it.", emailKey, emailKey); String taggerName = name.get(); String taggerEmail = email.get(); Platform platform = platform(); long taggerTimeStamp = platform.currentTimeMillis(); int taggerTimeZoneOffset = platform.timeZoneOffset(taggerTimeStamp); return RevPersonBuilder.build(taggerName, taggerEmail, taggerTimeStamp, taggerTimeZoneOffset); }
@Test public void testInvalidTagName() throws Exception { insertAndAdd(points1); RevCommit commit = geogig.command(CommitOp.class).call(); exception.expect(IllegalArgumentException.class); exception.expectMessage("Component of ref cannot have two consecutive dots (..) anywhere."); geogig.command(TagCreateOp.class).setCommitId(commit.getId()).setName("Tag..1").call(); }
@Test public void testInvalidTagName() throws Exception { insertAndAdd(points1); RevCommit commit = geogig.command(CommitOp.class).call(); exception.expect(IllegalArgumentException.class); exception.expectMessage("Component of ref cannot have two consecutive dots (..) anywhere."); geogig.command(TagCreateOp.class).setCommitId(commit.getId()).setName("Tag..1").call(); }
@Given("^I have a remote tag called \"([^\"]*)\"$") public void i_have_a_remote_tag_called(String expected) throws Throwable { localRepo.geogigCLI.getGeogig(Hints.readWrite()) // .command(TagCreateOp.class) // .setName(expected) // .setMessage("Tagged " + expected) // .setCommitId(ObjectId.NULL) // .call(); }
@Test public void testTagCreation() throws Exception { insertAndAdd(points1); RevCommit commit = geogig.command(CommitOp.class).call(); RevTag tag = geogig.command(TagCreateOp.class).setCommitId(commit.getId()).setName("Tag1") .call(); Optional<RevTag> databaseTag = geogig.command(RevObjectParse.class).setRefSpec("Tag1") .call(RevTag.class); assertTrue(databaseTag.isPresent()); assertEquals(tag, databaseTag.get()); }
/** * Executes the tag creation operation. * * @return the created tag * */ @Override protected RevTag _call() throws RuntimeException { checkState(name != null, "tag name was not provided"); final String tagRefPath = Ref.TAGS_PREFIX + name; checkArgument(!command(RefParse.class).setName(tagRefPath).call().isPresent(), "A tag named '" + name + "' already exists."); command(CheckRefFormat.class).setThrowsException(true).setRef(tagRefPath).call(); if (commitId == null) { final Optional<Ref> currHead = command(RefParse.class).setName(Ref.HEAD).call(); Preconditions.checkState(currHead.isPresent(), "Repository has no HEAD, can't create tag"); commitId = currHead.get().getObjectId(); } RevPerson tagger = resolveTagger(); message = message == null ? "" : message; final RevTag tag = RevTag.builder().name(name).commitId(commitId).message(message) .tagger(tagger).build(); objectDatabase().put(tag); Optional<Ref> branchRef = command(UpdateRef.class).setName(tagRefPath) .setNewValue(tag.getId()).call(); checkState(branchRef.isPresent()); return tag; }
@Given("^I have a remote tag called \"([^\"]*)\"$") public void i_have_a_remote_tag_called(String expected) throws Throwable { localRepo.geogigCLI.getGeogig(Hints.readWrite()) // .command(TagCreateOp.class) // .setName(expected) // .setMessage("Tagged " + expected) // .setCommitId(ObjectId.NULL) // .call(); }
@Test public void testTagCreation() throws Exception { insertAndAdd(points1); RevCommit commit = geogig.command(CommitOp.class).call(); RevTag tag = geogig.command(TagCreateOp.class).setCommitId(commit.getId()).setName("Tag1") .call(); Optional<RevTag> databaseTag = geogig.command(RevObjectParse.class).setRefSpec("Tag1") .call(RevTag.class); assertTrue(databaseTag.isPresent()); assertEquals(tag, databaseTag.get()); }
@Given("^There is a tag called \"([^\"]*)\" on the \"([^\"]*)\" repo pointing to \"([^\"]*)\" with the \"([^\"]*)\" message$") public void There_is_a_tag(String tagName, String repoName, String target, String message) { Repository repo = context.getRepo(repoName); target = context.replaceVariables(target); repo.command(TagCreateOp.class).setName(tagName).setCommitId(ObjectId.valueOf(target)) .setMessage(message).call(); // add the repo to the set so it can be closed openedRepos.add(repoName); }
@Test public void testTagRemoval() throws Exception { insertAndAdd(points1); RevCommit commit = geogig.command(CommitOp.class).call(); RevTag tag = geogig.command(TagCreateOp.class).setCommitId(commit.getId()).setName("Tag1") .call(); Optional<RevTag> databaseTag = geogig.command(RevObjectParse.class).setRefSpec("Tag1") .call(RevTag.class); assertTrue(databaseTag.isPresent()); RevTag removedTag = geogig.command(TagRemoveOp.class).setName("Tag1").call(); assertEquals(tag, removedTag); Optional<ObjectId> databaseTagId = geogig.command(RevParse.class).setRefSpec("Tag1").call(); assertFalse(databaseTagId.isPresent()); }
/** * Executes the commit command using the provided options. */ @Override public void runInternal(GeogigCLI cli) throws IOException { checkParameter((message != null && !message.trim().isEmpty()) || nameAndCommit.isEmpty() || delete, "No tag message provided"); checkParameter(nameAndCommit.size() < 2 || (nameAndCommit.size() == 2 && !delete), "Too many parameters provided"); if (nameAndCommit.isEmpty()) { // looks like an attempt to create a tag with a message but forgot the tag name checkParameter(message == null, "A tag name must be provided"); listTags(cli); return; } String name = nameAndCommit.get(0); String commit = nameAndCommit.size() > 1 ? nameAndCommit.get(1) : Ref.HEAD; Console console = cli.getConsole(); final GeoGIG geogig = cli.getGeogig(); if (delete) { geogig.command(TagRemoveOp.class).setName(name).call(); console.println("Deleted tag " + name); } else { Optional<ObjectId> commitId = geogig.command(RevParse.class).setRefSpec(commit).call(); checkParameter(commitId.isPresent(), "Wrong reference: " + commit); RevTag tag = geogig.command(TagCreateOp.class).setName(name).setMessage(message) .setCommitId(commitId.get()).call(); console.println("Created tag " + name + " -> " + tag.getCommitId()); } }
@Test public void testTagRemoval() throws Exception { insertAndAdd(points1); RevCommit commit = geogig.command(CommitOp.class).call(); RevTag tag = geogig.command(TagCreateOp.class).setCommitId(commit.getId()).setName("Tag1") .call(); Optional<RevTag> databaseTag = geogig.command(RevObjectParse.class).setRefSpec("Tag1") .call(RevTag.class); assertTrue(databaseTag.isPresent()); RevTag removedTag = geogig.command(TagRemoveOp.class).setName("Tag1").call(); assertEquals(tag, removedTag); Optional<ObjectId> databaseTagId = geogig.command(RevParse.class).setRefSpec("Tag1").call(); assertFalse(databaseTagId.isPresent()); }
/** * Executes the commit command using the provided options. */ @Override public void runInternal(GeogigCLI cli) throws IOException { checkParameter((message != null && !message.trim().isEmpty()) || nameAndCommit.isEmpty() || delete, "No tag message provided"); checkParameter(nameAndCommit.size() < 2 || (nameAndCommit.size() == 2 && !delete), "Too many parameters provided"); if (nameAndCommit.isEmpty()) { // looks like an attempt to create a tag with a message but forgot the tag name checkParameter(message == null, "A tag name must be provided"); listTags(cli); return; } String name = nameAndCommit.get(0); String commit = nameAndCommit.size() > 1 ? nameAndCommit.get(1) : Ref.HEAD; Console console = cli.getConsole(); final GeoGIG geogig = cli.getGeogig(); if (delete) { geogig.command(TagRemoveOp.class).setName(name).call(); console.println("Deleted tag " + name); } else { Optional<ObjectId> commitId = geogig.command(RevParse.class).setRefSpec(commit).call(); checkParameter(commitId.isPresent(), "Wrong reference: " + commit); RevTag tag = geogig.command(TagCreateOp.class).setName(name).setMessage(message) .setCommitId(commitId.get()).call(); console.println("Created tag " + name + " -> " + tag.getCommitId()); } }
.setObjectId(oId).call(); assertTrue(childObject.isPresent()); RevTag tag = remoteRepo.command(TagCreateOp.class).setCommitId(commit.getId()) .setName(f.getIdentifier().getID()).call(); tags.add(tag);
/** * Executes the commit command using the provided options. */ @Override public void runInternal(GeogigCLI cli) throws IOException { checkParameter((message != null && !message.trim().isEmpty()) || nameAndCommit.isEmpty() || delete, "No tag message provided"); checkParameter(nameAndCommit.size() < 2 || (nameAndCommit.size() == 2 && !delete), "Too many parameters provided"); if (nameAndCommit.isEmpty()) { // looks like an attempt to create a tag with a message but forgot the tag name checkParameter(message == null, "A tag name must be provided"); listTags(cli); return; } String name = nameAndCommit.get(0); String commit = nameAndCommit.size() > 1 ? nameAndCommit.get(1) : Ref.HEAD; Console console = cli.getConsole(); final GeoGIG geogig = cli.getGeogig(); if (delete) { geogig.command(TagRemoveOp.class).setName(name).call(); console.println("Deleted tag " + name); } else { Optional<ObjectId> commitId = geogig.command(RevParse.class).setRefSpec(commit).call(); checkParameter(commitId.isPresent(), "Wrong reference: " + commit); RevTag tag = geogig.command(TagCreateOp.class).setName(name).setMessage(message) .setCommitId(commitId.get()).call(); console.println("Created tag " + name + " -> " + tag.getCommitId()); } }
.setObjectId(oId).call(); assertTrue(childObject.isPresent()); RevTag tag = remoteRepo.command(TagCreateOp.class).setCommitId(commit.getId()) .setName(f.getIdentifier().getID()).call(); tags.add(tag);
throw new CommandSpecException("'" + commit + "' could not be resolved."); final RevTag tag = geogig.command(TagCreateOp.class).setName(name).setMessage(message) .setCommitId(commitId.get()).call(); context.setResponseContent(new CommandResponse() { @Override