[Documentation] Improve revwalk examples. Finding last change to file?
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 2.1k
- Forks
- 450
- Avg merge
- 11m
- Merged PRs (30d)
- 1
Description
The revwalk documentation is unclear about how to find the last commit changing a file (a pretty basic usage).
Example:
fn recipe_modified(path: PathBuf) -> Result<i32, Box<dyn Error>> {
let repo = git2::Repository::discover(path)?;
let mut revwalk = repo.revwalk()?;
revwalk.push_head()?;
revwalk.set_sorting(git2::Sort::TIME)?;
for rev in revwalk {
let commit = repo.find_commit(rev?)?;
let message = commit.summary_bytes().unwrap_or_else(|| commit.message_bytes());
println!("{}\t{}", commit.id(), String::from_utf8_lossy(message));
}
Ok(0)
}
Here, provided a git repo, we pull all of the commits for it.. but I don't see a clear way to:
- Check the files included in a commit.
- Revwalk only on commits impacting a file.
This seems like a really common usage scenario, but little documentation on it,
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the revwalk documentation and the shown Repository::revwalk, push_head, set_sorting, and find_commit example. Check the git2-rs API for inspecting commit trees and restricting traversal, then update the documentation with clear examples for finding changed files and the last commit affecting a file; done means both common workflows are explained accurately.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, rust
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100