Skip to content

Commit ccefef1

Browse files
authored
Merge pull request #4 from jnises/more-fixes
More fixes
2 parents ddccf52 + 55d071c commit ccefef1

File tree

4 files changed

+29
-22
lines changed

4 files changed

+29
-22
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "git-suggest-reviewers"
3-
version = "1.4.0"
3+
version = "1.4.1"
44
authors = ["Joel Nises <[email protected]>"]
55
edition = "2018"
66

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
git-suggest-reviewers
2-
===================
1+
# git-suggest-reviewers
2+
33
Tool that suggests which reviewers to pick for a PR based on who have previously authored the lines modified by the PR.
44

5-
requirements
6-
------------
5+
## requirements
6+
77
rust (https://rustup.rs/)
88

9-
build
10-
-----
9+
## build
10+
1111
`cargo build --release`
1212

13-
usage
14-
-----
13+
## usage
14+
1515
USAGE:
1616
git-suggest-reviewers [FLAGS] [OPTIONS] <base> <compare>
1717

@@ -22,23 +22,24 @@ usage
2222
-v, --verbose Verbose mode (-v, -vv, -vvv, etc), disables progress bar
2323

2424
OPTIONS:
25-
--context <context> How many lines around each modification to count [default: 1]
26-
--first-commit <first-commit> Don't look further back than this when blaming files
27-
--max-file-size <max-file-size> Ignore files larger than this (in bytes) to make things faster
25+
--context <context> How many lines around each modification to count [default: 1]
26+
-j, --max-concurrency <max-concurrency> [default: 0]
27+
--stop-at <stop-at> Try not to look further back than this commit when blaming files
2828

2929
ARGS:
3030
<base> Where to merge to
3131
<compare> Where to merge from
3232

33-
3433
Output will be on lines on the form
34+
3535
```
3636
3737
38-
100 Ramon <[email protected]>
38+
100 Ramon <[email protected]>
3939
```
40+
4041
sorted by the number of lines authored by that developer.
4142

42-
known issues
43-
------------
44-
Built using libgit2, so only supports repos that that library can handle.
43+
## known issues
44+
45+
Built using libgit2, so only supports repos that that library can handle.

src/main.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,13 @@ fn main() -> Result<()> {
7474
let base = repo
7575
.revparse_single(&opt.base)
7676
.context("unable to find base")?
77+
.peel_to_commit()?
7778
.id();
7879
info!("base: {}", base);
7980
let compare = repo
8081
.revparse_single(&opt.compare)
8182
.context("unable to find compare")?
83+
.peel_to_commit()?
8284
.id();
8385
info!("compare: {}", compare);
8486
let merge_base = repo
@@ -89,6 +91,7 @@ fn main() -> Result<()> {
8991
let mut commit = repo
9092
.revparse_single(&stop_at)
9193
.context("unable to find stop_at commit")?
94+
.peel_to_commit()?
9295
.id();
9396
let base = repo.merge_base(merge_base, commit)?;
9497
if base != commit {
@@ -181,12 +184,16 @@ fn main() -> Result<()> {
181184
hunk.old_start()..(hunk.old_start() + hunk.old_lines())
182185
{
183186
if let Some(oldhunk) = blame.get_line(line as usize) {
184-
if let Some(commit) = stop_at {
185-
let key = (commit, oldhunk.final_commit_id());
187+
if let Some(stop) = stop_at {
188+
let line_commit = oldhunk.final_commit_id();
189+
if line_commit == stop {
190+
continue;
191+
}
192+
let key = (stop, line_commit);
186193
let mut map = merge_base_tls.get_or_default().borrow_mut();
187194
let base = map.entry(key).or_insert_with(|| repo.merge_base(key.0, key.1).ok());
188195
if let Some(b) = base {
189-
if *b != commit {
196+
if *b != stop {
190197
// this seems to happen a lot. oldest_commit on blame options doesn't seem to do what I expected :(
191198
continue;
192199
}
@@ -203,7 +210,6 @@ fn main() -> Result<()> {
203210
if signptr.raw.is_null() {
204211
warn!("bad signature found in file: {:?}. might be an author without an email or something (bug in libgit2)", old_path);
205212
} else {
206-
debug!("path: {:?} commit: {} line: {}", old_path, oldhunk.final_commit_id(), line);
207213
let author = (
208214
sign.name().map(String::from),
209215
sign.email().map(String::from),

0 commit comments

Comments
 (0)