Skip to content

Conversation

@namrathamyske
Copy link
Contributor

@namrathamyske namrathamyske commented Aug 8, 2022

As addressed by #5150 (comment), creating a separate PR for tags.

#5150 will make use of this PR.

@amogh-jahagirdar @rdblue let me know what you think!

Preconditions.checkArgument(table().snapshot(tag) != null, "Cannot find tag with name %s", tag);
Preconditions.checkArgument(
table().refs().get(tag).isTag(), "Ref %s is a branch, not a tag", tag);
return useSnapshot(table().snapshot(tag).snapshotId());
Copy link
Contributor

@hililiwei hililiwei Aug 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    SnapshotRef ref = tableOps().current().ref(tag);
    Preconditions.checkArgument(ref != null, "Tag does not exist: %s", tag);
    Preconditions.checkArgument(ref.isTag(), "Ref %s is a tag not a branch", tag);

The error message is modified to be consistent with that in UpdateSnapshotReferencesOperations.

public UpdateSnapshotReferencesOperation removeTag(String name) {
Preconditions.checkNotNull(name, "Tag name cannot be null");
SnapshotRef ref = updatedRefs.remove(name);
Preconditions.checkArgument(ref != null, "Tag does not exist: %s", name);
Preconditions.checkArgument(ref.isTag(), "Ref %s is a branch not a tag", name);
return this;
}
public UpdateSnapshotReferencesOperation renameBranch(String name, String newName) {
Preconditions.checkNotNull(name, "Branch to rename cannot be null");
Preconditions.checkNotNull(newName, "New branch name cannot be null");
Preconditions.checkArgument(!name.equals(SnapshotRef.MAIN_BRANCH), "Cannot rename main branch");
SnapshotRef ref = updatedRefs.get(name);
Preconditions.checkArgument(ref != null, "Branch does not exist: %s", name);
Preconditions.checkArgument(ref.isBranch(), "Ref %s is a tag not a branch", name);
SnapshotRef existing = updatedRefs.put(newName, ref);
Preconditions.checkArgument(existing == null, "Ref %s already exists", newName);
updatedRefs.remove(name, ref);
return this;

@rdblue
Copy link
Contributor

rdblue commented Aug 10, 2022

I think we've decided to go with useRef rather than separate tag and branch methods. I'll close this. Thanks, @namrathamyske!

@rdblue rdblue closed this Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants