Skip to content

Feature/add libra tag #775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

xsrkt26
Copy link
Contributor

@xsrkt26 xsrkt26 commented Dec 22, 2024

New features or issues fixed: Added the tag command to Libra.
Purpose of the changes: Improve the implementation of Libra.
Supported functionality: libra tag [OPTIONS] [TAG_NAME] [COMMIT_HASH]

Copy link

vercel bot commented Dec 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mega ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 20, 2025 2:03am

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (5)

libra/src/internal/tag.rs:42

  • Using unwrap() can cause a panic if the result is None. Consider handling the None case more gracefully.
unwrap()

libra/src/internal/tag.rs:75

  • Using unwrap() can cause a panic if the result is None. Consider handling the None case more gracefully.
unwrap()

libra/src/internal/tag.rs:86

  • Using unwrap() can cause a panic if the result is None. Consider handling the None case more gracefully.
unwrap()

libra/src/command/tag.rs:90

  • Avoid panicking; handle the error more gracefully.
let _ = load_object::<Commit>(&commit_id).unwrap_or_else(|_| panic!("fatal: not a valid object name: '{}'", commit_id));

libra/src/command/tag.rs:128

  • Avoid panicking; handle the error more gracefully.
let _ = TagInfo::find_tag(&tag_name).await.unwrap_or_else(|| panic!("fatal: tag '{}' not found", tag_name));

.filter(reference::Column::Kind.eq(reference::ConfigKind::Tag))
.one(db_conn)
.await
.unwrap()
Copy link
Preview

Copilot AI Dec 22, 2024

Choose a reason for hiding this comment

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

Using unwrap() can cause a panic if the result is None. Consider handling the None case more gracefully.

Suggested change
.unwrap()
.await.ok()?

Copilot uses AI. Check for mistakes.

match tag {
Some(tag) => Some(TagInfo {
name: tag.name.as_ref().unwrap().clone(),
commit: SHA1::from_str(tag.commit.as_ref().unwrap()).unwrap(),
Copy link
Preview

Copilot AI Dec 22, 2024

Choose a reason for hiding this comment

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

Using unwrap() can cause a panic if the result is None. Consider handling the None case more gracefully.

Suggested change
commit: SHA1::from_str(tag.commit.as_ref().unwrap()).unwrap(),
commit: tag.commit.as_ref().and_then(|c| SHA1::from_str(c).ok()),

Copilot uses AI. Check for mistakes.

// default behavior
list_tags().await;
} else {
panic!("should not reach here")
Copy link
Preview

Copilot AI Dec 22, 2024

Choose a reason for hiding this comment

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

Unexpected cases should be handled more gracefully instead of panicking.

Suggested change
panic!("should not reach here")
eprintln!("Error: unexpected case encountered");

Copilot uses AI. Check for mistakes.

tracing::debug!("create tag: {} from {:?}", tag_name, commit_hash);

if !is_valid_git_tag_name(&tag_name) {
eprintln!("fatal: invalid tag name: {}", tag_name);
Copy link
Preview

Copilot AI Dec 22, 2024

Choose a reason for hiding this comment

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

Returning an error would be more appropriate than just printing and returning.

Suggested change
eprintln!("fatal: invalid tag name: {}", tag_name);
return Err(format!("fatal: invalid tag name: {}", tag_name));

Copilot uses AI. Check for mistakes.

Copy link
Member

@genedna genedna left a comment

Choose a reason for hiding this comment

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

@xsrkt26

Please add the docs for the tag and config commands. They will be displayed at https://gitmega.dev/docs/libra/command/tag and https://gitmega.dev/docs/libra/command/config. The docs file is located in aria/contents/docs/libra/command/tag/index.mdx and aria/contents/docs/libra/command/config/index.mdx.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 6 out of 8 changed files in this pull request and generated 1 comment.

Files not reviewed (2)
  • aria/contents/docs/libra/command/config/index.mdx: Language not supported
  • aria/contents/docs/libra/command/tag/index.mdx: Language not supported
Comments suppressed due to low confidence (2)

libra/src/internal/tag.rs:68

  • The comment should be 'Check if the tag exists'.
// check if tag exists

libra/src/cli.rs:66

  • The comment should start with a capital letter: "Set tag for the current commit".
#[command(about = "set tag for the current commit")]

.collect()
}

/// is the tag exists
Copy link
Preview

Copilot AI Feb 20, 2025

Choose a reason for hiding this comment

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

The comment should be 'Check if the tag exists'.

Suggested change
/// is the tag exists
/// Check if the tag exists

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants