rust-lang / rust-lang/git2-rs

`Object::as_tag` does not seems to work as expected.

Open
#536 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
2.1k
Forks
450
Avg merge
11m
Merged PRs (30d)
1

Description

I've been playing with the tag example, the method Object::as_tag always return none unless the tag has a message :

if let Some(tag) = obj.as_tag() {
                print_tag(tag, args);
            } else if let Some(commit) = obj.as_commit() {
                print_commit(commit, name, args);
            } else {
                print_name(name);
            }
  • tagging a commit with git tag v0.0.0 and trying to convert the corresponding object to a tag will return None.
  • tagging a commit with git tag -a v0.0.0 -m "some message" and trying to convert the corresponding object to a tag will return Some(Tag { name: "v0.0.0", id: oid... })

Is this an expected behavior ? If it is, It might be a good idea to document it. I'd be happy to submit a PR.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with examples/tag.rs and the Object::as_tag API, then reproduce the two cases using lightweight and annotated git tags. Check whether the differing results are expected for the underlying object types; done means the behavior is clarified and the relevant API documentation or conversion is updated as appropriate.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, rust
Domain
devtools
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.