Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix check to detect git-lfs managed files that weren't checked out. #1733

Merged
merged 3 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions gix-revision/src/spec/parse/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,23 @@ where
}
} else if has_ref_or_implied_name {
delegate
.reflog(delegate::ReflogLookup::Entry(
n.try_into().expect("non-negative isize fits usize"),
))
.reflog(if n >= 100000000 {
let time = nav
.to_str()
.map_err(|_| Error::Time {
input: nav.into(),
source: None,
})
.and_then(|date| {
gix_date::parse(date, None).map_err(|err| Error::Time {
input: nav.into(),
source: err.into(),
})
})?;
delegate::ReflogLookup::Date(time)
} else {
delegate::ReflogLookup::Entry(n.try_into().expect("non-negative isize fits usize"))
})
.ok_or(Error::Delegate)?;
} else {
return Err(Error::ReflogLookupNeedsRefName { name: (*name).into() });
Expand Down
25 changes: 25 additions & 0 deletions gix-revision/tests/revision/spec/parse/anchor/at_symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,31 @@ fn reflog_by_date_for_current_branch() {
assert_eq!(rec.calls, 1);
}

#[test]
fn reflog_by_unix_timestamp_for_current_branch() {
let rec = parse("@{100000000}");

assert!(rec.kind.is_none());
assert_eq!(rec.find_ref[0], None,);
assert_eq!(
rec.prefix[0], None,
"neither ref nor prefixes are set, straight to navigation"
);
assert_eq!(
rec.current_branch_reflog_entry[0],
Some("100000000 +0000".to_string()),
"This number is the first to count as date"
);
assert_eq!(rec.calls, 1);

let rec = parse("@{99999999}");
assert_eq!(
rec.current_branch_reflog_entry[0],
Some("99999999".to_string()),
"one less is an offset though"
);
}

#[test]
fn reflog_by_date_with_date_parse_failure() {
let err = try_parse("@{foo}").unwrap_err();
Expand Down
10 changes: 7 additions & 3 deletions gix/tests/gix/repository/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@ mod revision {
fn date() -> crate::Result {
let repo = crate::named_repo("make_rev_parse_repo.sh")?;
let actual = repo
.rev_parse_single("old@{10 years ago}")
.rev_parse_single("old@{20 years ago}")
.expect("it returns the oldest possible rev when overshooting");
assert_eq!(actual, hex_to_id("be2f093f0588eaeb71e1eff7451b18c2a9b1d765"));

let actual = repo
.rev_parse_single("old@{1 month ago}")
.rev_parse_single("old@{1732184844}")
.expect("it finds something in the middle");
assert_eq!(actual, hex_to_id("b29405fe9147a3a366c4048fbe295ea04de40fa6"));
assert_eq!(
actual,
hex_to_id("b29405fe9147a3a366c4048fbe295ea04de40fa6"),
"It also figures out that we don't mean an index, but a date"
);
Ok(())
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/tools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ fn should_skip_all_archive_creation() -> bool {
}

fn is_lfs_pointer_file(path: &Path) -> bool {
const PREFIX: &[u8] = b"version https://gix-lfs";
const PREFIX: &[u8] = b"version https://git-lfs";
let mut buf = [0_u8; PREFIX.len()];
std::fs::OpenOptions::new()
.read(true)
Expand Down
Loading