Commit
Author: Kevin Schoon [me@kevinschoon.com]
Hash: eae458778627dcbfb7497f74822ca9124e9712f3
Timestamp: Sat, 30 Mar 2024 13:20:15 +0000 (1 year ago)

+12 -8 +/-1 browse
fix timezone in test_git_commit_range
1diff --git a/crates/git/src/wrapper.rs b/crates/git/src/wrapper.rs
2index 9af7620..79dcdd5 100644
3--- a/crates/git/src/wrapper.rs
4+++ b/crates/git/src/wrapper.rs
5 @@ -179,6 +179,10 @@ impl Wrapper {
6 Ok(tags)
7 }
8
9+ pub fn branches_range(&self, timeframe: Option<(i64, i64)>) -> Result<(), Error> {
10+ Ok(())
11+ }
12+
13 // create a worktree and expose it to the function any always clean up
14 // the tree even if the given function crashes.
15 pub fn with_worktree<F>(
16 @@ -912,15 +916,15 @@ mod tests {
17 .resolve_tree(None, &tree, None)
18 .expect("failed to populate tree");
19 assert!(commits.len() == 4);
20- let c1 = commits.iter().nth(0).unwrap();
21+ let c1 = commits.first().unwrap();
22 assert!(c1.message.trim_end() == "commit 1");
23- let c2 = commits.iter().nth(1).unwrap();
24+ let c2 = commits.get(1).unwrap();
25 println!("c2: {}", c2.message);
26 assert!(c2.message.trim_end() == "commit 2");
27- let c3 = commits.iter().nth(2).unwrap();
28+ let c3 = commits.get(2).unwrap();
29 println!("c3: {}", c3.message);
30 assert!(c3.message.trim_end() == "commit 3");
31- let c4 = commits.iter().nth(3).unwrap();
32+ let c4 = commits.get(3).unwrap();
33 println!("c4: {}", c4.message);
34 assert!(c4.message.trim_end() == "commit 4");
35 fs::remove_dir_all(repo_path).expect("failed to clean up repository")
36 @@ -928,9 +932,9 @@ mod tests {
37
38 #[test]
39 fn test_git_commit_range() {
40- let timestamp_1 = "Fri Jul 14 03:40:00 AM WEST 2017"; // @1500000000
41- let timestamp_2 = "Fri Jul 14 03:40:01 AM WEST 2017"; // @1500000001
42- let timestamp_3 = "Sun Sep 13 01:26:40 PM WEST 2020"; // @1600000000
43+ let timestamp_1 = "Fri Jul 14 02:40:00 AM UTC 2017"; // @1500000000
44+ let timestamp_2 = "Fri Jul 14 02:40:01 AM UTC 2017"; // @1500000001
45+ let timestamp_3 = "Sun Sep 13 12:26:40 PM UTC 2020"; // @1600000000
46 let mut test_repo = testing::Builder::default().with_commands(vec![
47 format!("echo 'content' > file_1.txt && git add file_1.txt && GIT_COMMITTER_DATE='{}' GIT_AUTHOR_DATE='{}' git commit -m 'commit 1'", timestamp_1, timestamp_1).as_str(),
48 format!("echo 'content' > file_2.txt && git add file_2.txt && GIT_COMMITTER_DATE='{}' GIT_AUTHOR_DATE='{}' git commit -m 'commit 2'", timestamp_2, timestamp_2).as_str(),
49 @@ -939,7 +943,7 @@ mod tests {
50 let repo_path = test_repo.build().expect("failed to init repo").1;
51 let repository = Wrapper::new(&repo_path).expect("failed to load repository");
52 let commits = repository
53- .commits_range(None, Some((1500000000, 1550000000)))
54+ .commits_range(None, Some((1499999999, 1550000000)))
55 .expect("failed to get range");
56 assert!(commits.len() == 2);
57 assert!(commits[0].message.trim_end() == "commit 2");