Showing the changes to git-commitgraph (6 of 7 files). Show all
Unified · Split
| @@ -1,4 +1,70 @@ | |||
| 1 | mod octopus_merges; | 1 | use crate::{check_common, create_repo, inspect_refs}; |
| 2 | mod single_commit; | 2 | use git_commitgraph::Graph; |
| 3 | mod single_parent; | 3 | |
| 4 | mod two_parents; | 4 | #[test] |
| 5 | fn single_parent() -> Result<(), Box<dyn std::error::Error>> { | ||
| 6 | let repo_dir = create_repo("single_parent.sh"); | ||
| 7 | let refs = inspect_refs(repo_dir.path(), &["parent", "child"]); | ||
| 8 | let cg = Graph::from_info_dir(repo_dir.path().join(".git").join("objects").join("info"))?; | ||
| 9 | check_common(&cg, &refs); | ||
| 10 | |||
| 11 | assert_eq!(cg.commit_at(refs["parent"].pos()).generation(), 1); | ||
| 12 | assert_eq!(cg.commit_at(refs["child"].pos()).generation(), 2); | ||
| 13 | |||
| 14 | Ok(()) | ||
| 15 | } | ||
| 16 | |||
| 17 | #[test] | ||
| 18 | fn octupus_merges() -> Result<(), Box<dyn std::error::Error>> { | ||
| 19 | let repo_dir = create_repo("octopus_merges.sh"); | ||
| 20 | let refs = inspect_refs( | ||
| 21 | repo_dir.path(), | ||
| 22 | &[ | ||
| 23 | "root", | ||
| 24 | "parent1", | ||
| 25 | "parent2", | ||
| 26 | "parent3", | ||
| 27 | "parent4", | ||
| 28 | "three_parents", | ||
| 29 | "four_parents", | ||
| 30 | ], | ||
| 31 | ); | ||
| 32 | let cg = Graph::from_info_dir(repo_dir.path().join(".git").join("objects").join("info"))?; | ||
| 33 | check_common(&cg, &refs); | ||
| 34 | |||
| 35 | assert_eq!(cg.commit_at(refs["root"].pos()).generation(), 1); | ||
| 36 | assert_eq!(cg.commit_at(refs["parent1"].pos()).generation(), 2); | ||
| 37 | assert_eq!(cg.commit_at(refs["parent2"].pos()).generation(), 2); | ||
| 38 | assert_eq!(cg.commit_at(refs["parent3"].pos()).generation(), 2); | ||
| 39 | assert_eq!(cg.commit_at(refs["parent4"].pos()).generation(), 2); | ||
| 40 | assert_eq!(cg.commit_at(refs["three_parents"].pos()).generation(), 3); | ||
| 41 | assert_eq!(cg.commit_at(refs["four_parents"].pos()).generation(), 3); | ||
| 42 | |||
| 43 | Ok(()) | ||
| 44 | } | ||
| 45 | |||
| 46 | #[test] | ||
| 47 | fn single_commit() -> Result<(), Box<dyn std::error::Error>> { | ||
| 48 | let repo_dir = create_repo("single_commit.sh"); | ||
| 49 | let refs = inspect_refs(repo_dir.path(), &["commit"]); | ||
| 50 | let cg = Graph::from_info_dir(repo_dir.path().join(".git").join("objects").join("info"))?; | ||
| 51 | check_common(&cg, &refs); | ||
| 52 | |||
| 53 | assert_eq!(cg.commit_at(refs["commit"].pos()).generation(), 1); | ||
| 54 | |||
| 55 | Ok(()) | ||
| 56 | } | ||
| 57 | |||
| 58 | #[test] | ||
| 59 | fn two_parents() -> Result<(), Box<dyn std::error::Error>> { | ||
| 60 | let repo_dir = create_repo("two_parents.sh"); | ||
| 61 | let refs = inspect_refs(repo_dir.path(), &["parent1", "parent2", "child"]); | ||
| 62 | let cg = Graph::from_info_dir(repo_dir.path().join(".git").join("objects").join("info"))?; | ||
| 63 | check_common(&cg, &refs); | ||
| 64 | |||
| 65 | assert_eq!(cg.commit_at(refs["parent1"].pos()).generation(), 1); | ||
| 66 | assert_eq!(cg.commit_at(refs["parent2"].pos()).generation(), 1); | ||
| 67 | assert_eq!(cg.commit_at(refs["child"].pos()).generation(), 2); | ||
| 68 | |||
| 69 | Ok(()) | ||
| 70 | } | ||
| @@ -1,31 +0,0 @@ | |||
| 1 | use crate::{check_common, create_repo, inspect_refs}; | ||
| 2 | use git_commitgraph::Graph; | ||
| 3 | |||
| 4 | #[test] | ||
| 5 | fn test() -> Result<(), Box<dyn std::error::Error>> { | ||
| 6 | let repo_dir = create_repo("octopus_merges.sh"); | ||
| 7 | let refs = inspect_refs( | ||
| 8 | repo_dir.path(), | ||
| 9 | &[ | ||
| 10 | "root", | ||
| 11 | "parent1", | ||
| 12 | "parent2", | ||
| 13 | "parent3", | ||
| 14 | "parent4", | ||
| 15 | "three_parents", | ||
| 16 | "four_parents", | ||
| 17 | ], | ||
| 18 | ); | ||
| 19 | let cg = Graph::from_info_dir(repo_dir.path().join(".git").join("objects").join("info"))?; | ||
| 20 | check_common(&cg, &refs); | ||
| 21 | |||
| 22 | assert_eq!(cg.commit_at(refs["root"].pos()).generation(), 1); | ||
| 23 | assert_eq!(cg.commit_at(refs["parent1"].pos()).generation(), 2); | ||
| 24 | assert_eq!(cg.commit_at(refs["parent2"].pos()).generation(), 2); | ||
| 25 | assert_eq!(cg.commit_at(refs["parent3"].pos()).generation(), 2); | ||
| 26 | assert_eq!(cg.commit_at(refs["parent4"].pos()).generation(), 2); | ||
| 27 | assert_eq!(cg.commit_at(refs["three_parents"].pos()).generation(), 3); | ||
| 28 | assert_eq!(cg.commit_at(refs["four_parents"].pos()).generation(), 3); | ||
| 29 | |||
| 30 | Ok(()) | ||
| 31 | } | ||
| @@ -1,14 +0,0 @@ | |||
| 1 | use crate::{check_common, create_repo, inspect_refs}; | ||
| 2 | use git_commitgraph::Graph; | ||
| 3 | |||
| 4 | #[test] | ||
| 5 | fn test() -> Result<(), Box<dyn std::error::Error>> { | ||
| 6 | let repo_dir = create_repo("single_commit.sh"); | ||
| 7 | let refs = inspect_refs(repo_dir.path(), &["commit"]); | ||
| 8 | let cg = Graph::from_info_dir(repo_dir.path().join(".git").join("objects").join("info"))?; | ||
| 9 | check_common(&cg, &refs); | ||
| 10 | |||
| 11 | assert_eq!(cg.commit_at(refs["commit"].pos()).generation(), 1); | ||
| 12 | |||
| 13 | Ok(()) | ||
| 14 | } | ||
| @@ -1,15 +0,0 @@ | |||
| 1 | use crate::{check_common, create_repo, inspect_refs}; | ||
| 2 | use git_commitgraph::Graph; | ||
| 3 | |||
| 4 | #[test] | ||
| 5 | fn test() -> Result<(), Box<dyn std::error::Error>> { | ||
| 6 | let repo_dir = create_repo("single_parent.sh"); | ||
| 7 | let refs = inspect_refs(repo_dir.path(), &["parent", "child"]); | ||
| 8 | let cg = Graph::from_info_dir(repo_dir.path().join(".git").join("objects").join("info"))?; | ||
| 9 | check_common(&cg, &refs); | ||
| 10 | |||
| 11 | assert_eq!(cg.commit_at(refs["parent"].pos()).generation(), 1); | ||
| 12 | assert_eq!(cg.commit_at(refs["child"].pos()).generation(), 2); | ||
| 13 | |||
| 14 | Ok(()) | ||
| 15 | } | ||
| @@ -1,16 +0,0 @@ | |||
| 1 | use crate::{check_common, create_repo, inspect_refs}; | ||
| 2 | use git_commitgraph::Graph; | ||
| 3 | |||
| 4 | #[test] | ||
| 5 | fn test() -> Result<(), Box<dyn std::error::Error>> { | ||
| 6 | let repo_dir = create_repo("two_parents.sh"); | ||
| 7 | let refs = inspect_refs(repo_dir.path(), &["parent1", "parent2", "child"]); | ||
| 8 | let cg = Graph::from_info_dir(repo_dir.path().join(".git").join("objects").join("info"))?; | ||
| 9 | check_common(&cg, &refs); | ||
| 10 | |||
| 11 | assert_eq!(cg.commit_at(refs["parent1"].pos()).generation(), 1); | ||
| 12 | assert_eq!(cg.commit_at(refs["parent2"].pos()).generation(), 1); | ||
| 13 | assert_eq!(cg.commit_at(refs["child"].pos()).generation(), 2); | ||
| 14 | |||
| 15 | Ok(()) | ||
| 16 | } | ||
| @@ -1,11 +1,13 @@ | |||
| 1 | use git_commitgraph::{Graph, GraphPosition}; | 1 | use git_commitgraph::{Graph, GraphPosition}; |
| 2 | use git_object::{borrowed, owned}; | 2 | use git_object::{borrowed, owned}; |
| 3 | use std::collections::{HashMap, HashSet}; | 3 | use std::{ |
| 4 | use std::convert::{TryFrom, TryInto}; | 4 | collections::{HashMap, HashSet}, |
| 5 | use std::hash::BuildHasher; | 5 | convert::{TryFrom, TryInto}, |
| 6 | use std::io::{BufRead, Cursor}; | 6 | hash::BuildHasher, |
| 7 | use std::path::{Path, PathBuf}; | 7 | io::{BufRead, Cursor}, |
| 8 | use std::process::Command; | 8 | path::{Path, PathBuf}, |
| 9 | process::Command, | ||
| 10 | }; | ||
| 9 | 11 | ||
| 10 | mod access; | 12 | mod access; |
| 11 | 13 | ||