You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Helper function to resolve and validate a revision to a commit ObjectId
67
+
let resolve_to_commit = |rev_str:&str,
68
+
context:Option<(&std::path::Path,usize)>|
69
+
-> anyhow::Result<gix::hash::ObjectId>{
70
+
let oid = repo.rev_parse_single(rev_str).map_err(|err| {
71
+
// Check for ambiguity error and provide exact message format
72
+
let err_str = err.to_string();
73
+
if err_str.contains("ambiguous") || err_str.contains("Ambiguous"){
74
+
anyhow!("error: revision '{}' is ambiguous; please use a longer SHA", rev_str)
75
+
}else{
76
+
match context {
77
+
Some((path, line)) => anyhow!(
78
+
"Invalid revision '{}' at line {} in file '{}': revision not found",
79
+
rev_str,
80
+
line,
81
+
path.display()
82
+
),
83
+
None => anyhow!("Invalid revision '{}': revision not found", rev_str),
84
+
}
85
+
}
86
+
})?;
87
+
88
+
// Peel to commit if it's a tag or other object
89
+
let peeled = repo.find_object(oid)
90
+
.with_context(|| "Failed to find object")?
91
+
.peel_to_kind(gix::object::Kind::Commit)
92
+
.with_context(|| match context {
93
+
Some((path, line)) => format!("Revision '{}' at line {} in file '{}' is not a commit (hint: use a commit SHA or tag that points to a commit)", rev_str, line, path.display()),
94
+
None => format!("Revision '{}' is not a commit (hint: use a commit SHA or tag that points to a commit)", rev_str),
95
+
})?;
96
+
97
+
Ok(peeled.id)
98
+
};
99
+
100
+
// Parse individual revision arguments
101
+
for rev_str in ignore_rev {
102
+
let commit_oid = resolve_to_commit(rev_str,None)?;
103
+
ignore_set.insert(commit_oid);
104
+
}
105
+
106
+
// Parse ignore-revs-files if provided
107
+
for file_path in ignore_revs_files {
108
+
// Resolve relative paths from repo root, not CWD
109
+
let resolved_path = if file_path.is_absolute(){
110
+
file_path.clone()
111
+
}else{
112
+
let repo_root = repo.workdir().unwrap_or_else(|| repo.git_dir());
113
+
repo_root.join(file_path)
114
+
};
115
+
116
+
let file_content = std::fs::read_to_string(&resolved_path)
117
+
.with_context(|| format!("Failed to read ignore-revs file: {}", file_path.display()))?;
118
+
119
+
// Strip UTF-8 BOM if present
120
+
let content = file_content.strip_prefix('\u{feff}').unwrap_or(&file_content);
0 commit comments