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); }
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); }
/** * 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; }
/** * 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; }