Skip to content

Add tag subcommand - #96

Merged
JohanMabille merged 2 commits into
QuantStack:mainfrom
SandrineP:tag_cmd
Feb 13, 2026
Merged

JohanMabille merged 2 commits into
QuantStack:mainfrom
SandrineP:tag_cmd

Conversation

@SandrineP

@SandrineP SandrineP commented Feb 10, 2026 •

Copy link
Copy Markdown
Collaborator

Fix #64
Add tag subcommand.

@SandrineP
SandrineP marked this pull request as ready for review February 10, 2026 17:01
@SandrineP SandrineP added the enhancement New feature or request label Feb 10, 2026

@ianthomas23 ianthomas23 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The git tag -l v* definitely won't work in the wasm build. so I'll need to support that soon.

Comment thread src/subcommand/tag_subcommand.cpp Outdated
{
return;
}
if (pos < message.length() && pos + 1 < message.length())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If pos + 1 < message.length() is true then pos < message.length() must also be so it is not necessary to check both.

}

// Tag listing: Print individual message lines
void print_list_lines(const std::string& message, int num_lines)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This function looks quite complicated for a relatively simple task. Maybe a better approach would be to first split the string at newline characters into a vector of strings and walk that vector. There is already a split-string-at-newlines function at

void terminal_pager::split_input_at_newlines(std::string_view str)

which could be pulled out of that file and reused.

But that could be in a later separate PR.

Comment thread src/subcommand/tag_subcommand.cpp Outdated
std::string pattern = m_tag_name.empty() ? "*" : m_tag_name;
auto tag_names = repo.tag_list_match(pattern);

for (size_t i = 0; i < tag_names.size(); i++)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Alternatively we could avoid the loop variable here by using a range-based for loop like this instead:

for (const auto& tag_name: tag_names)
{
    each_tag(repo, tag_name, m_num_lines);
}
Comment thread src/wrapper/repository_wrapper.cpp Outdated
throw_if_error(git_tag_list_match(&tag_names, pattern.c_str(), *this));

std::vector<std::string> result;
for (size_t i = 0; i < tag_names.count; ++i)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could use a range-based for loop here too.

Comment thread src/subcommand/tag_subcommand.cpp Outdated
throw git_exception("tag '" + m_tag_name + "' already exists", git2cpp_error_code::FILESYSTEM_ERROR);
}
throw git_exception("Unable to create annotated tag", error);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This method has a lot in common with create_lightweight_tag, maybe it would be worth extracting the common parts in small functions and have the create_XXX_tag be simple "drivers".

Comment thread src/subcommand/tag_subcommand.cpp Outdated
throw git_exception("Tag name required", git2cpp_error_code::GENERIC_ERROR);
}

if (m_message.empty())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This condition is already tested before calling create_tag, so this check can be removed.

@JohanMabille
JohanMabille merged commit 289f069 into QuantStack:main Feb 13, 2026
2 checks passed
@SandrineP
SandrineP deleted the tag_cmd branch February 16, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

3 participants