| @@ -128,3 +128,68 @@ fn author_and_committer_and_fallback() { · 127 unmodified lines |
| 128 | } | 128 | } |
| 129 | } | 129 | } |
| 130 | } | 130 | } |
| | 131 | |
| | 132 | #[test] |
| | 133 | #[serial] |
| | 134 | fn author_from_different_config_sections() { |
| | 135 | let repo = named_repo("make_signatures_repo.sh").unwrap(); |
| | 136 | let work_dir = repo.work_dir().unwrap().canonicalize().unwrap(); |
| | 137 | |
| | 138 | let _env = Env::new() |
| | 139 | .set( |
| | 140 | "GIT_CONFIG_GLOBAL", |
| | 141 | work_dir.join("global.config").display().to_string(), |
| | 142 | ) |
| | 143 | .set( |
| | 144 | "GIT_CONFIG_SYSTEM", |
| | 145 | work_dir.join("system.config").display().to_string(), |
| | 146 | ) |
| | 147 | .set("GIT_AUTHOR_DATE", "1979-02-26 18:30:00") |
| | 148 | .set("GIT_COMMITTER_DATE", "1980-02-26 18:30:00 +0000") |
| | 149 | .set("EMAIL", "general@email-unused"); |
| | 150 | |
| | 151 | let repo = git::open_opts( |
| | 152 | repo.git_dir(), |
| | 153 | repo.open_options() |
| | 154 | .clone() |
| | 155 | .with(git_sec::Trust::Full) |
| | 156 | .permissions(git::Permissions { |
| | 157 | env: git::permissions::Environment { |
| | 158 | xdg_config_home: Permission::Deny, |
| | 159 | home: Permission::Deny, |
| | 160 | ..git::permissions::Environment::all() |
| | 161 | }, |
| | 162 | ..Default::default() |
| | 163 | }), |
| | 164 | ) |
| | 165 | .unwrap(); |
| | 166 | |
| | 167 | assert_eq!( |
| | 168 | repo.author(), |
| | 169 | Some(git_actor::SignatureRef { |
| | 170 | name: "global name".into(), |
| | 171 | email: "local@example.com".into(), |
| | 172 | time: git_date::Time { |
| | 173 | seconds_since_unix_epoch: 42, |
| | 174 | offset_in_seconds: 1800, |
| | 175 | sign: git_date::time::Sign::Plus |
| | 176 | } |
| | 177 | }), |
| | 178 | ); |
| | 179 | assert_eq!( |
| | 180 | repo.committer(), |
| | 181 | Some(git_actor::SignatureRef { |
| | 182 | name: "local committer".into(), |
| | 183 | email: "global-committer@example.com".into(), |
| | 184 | time: git_date::Time { |
| | 185 | seconds_since_unix_epoch: 320437800, |
| | 186 | offset_in_seconds: 0, |
| | 187 | sign: git_date::time::Sign::Plus, |
| | 188 | } |
| | 189 | }) |
| | 190 | ); |
| | 191 | assert_eq!( |
| | 192 | repo.user_default().actor(), |
| | 193 | ("gitoxide".into(), "gitoxide@localhost".into()) |
| | 194 | ); |
| | 195 | } |