Skip to content

Commit cb090b9

Browse files
committed
Refactor adding commits to a vec to be in their own little scope
1 parent 0a77ad1 commit cb090b9

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/main.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,16 @@ fn main() -> Result<(), Box<Error>> {
120120
};
121121
let verbose = opt.verbose;
122122
let repo = Repository::open(&path)?;
123-
let mut revwalk = repo.revwalk()?;
124-
let mut commits: Vec<Commit> = Vec::new();
125-
revwalk.push_head()?;
126-
for commit in revwalk {
127-
let commit = repo.find_commit(commit?)?;
128-
commits.push(commit);
129-
}
123+
let commits = {
124+
let mut revwalk = repo.revwalk()?;
125+
let mut commits: Vec<Commit> = Vec::new();
126+
revwalk.push_head()?;
127+
for commit_id in revwalk {
128+
let commit = repo.find_commit(commit_id?)?;
129+
commits.push(commit);
130+
}
131+
commits
132+
};
130133
let mut repo = Repo::new(path.file_name().unwrap().to_str().unwrap());
131134
for commit in &commits {
132135
let commit_message = commit

0 commit comments

Comments
 (0)