Skip to content

Commit d79c78d

Browse files
committed
wip
1 parent c021b80 commit d79c78d

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

.github/actions/clippy-annotation-reporter/action.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ inputs:
1111
description: 'Comma-separated list of clippy rules to track'
1212
required: false
1313
default: 'unwrap_used,expect_used,todo,unimplemented,panic,unreachable'
14+
base-branch:
15+
description: 'Base branch to compare against'
16+
required: false
17+
default: 'origin/main'
1418

1519
runs:
1620
using: 'composite'
@@ -19,6 +23,13 @@ runs:
1923
shell: bash
2024
run: rustup install stable && rustup default stable
2125

26+
- name: Fetch all branches
27+
shell: bash
28+
run: |
29+
git fetch --all
30+
echo "Available branches:"
31+
git branch -a
32+
2233
- name: Build annotation reporter
2334
shell: bash
2435
run: |
@@ -33,5 +44,6 @@ runs:
3344
--rules "${{ inputs.allow-annotation-rules }}" \
3445
--repo "${{ github.repository }}" \
3546
--pr "${{ github.event.number }}"
47+
--base-branch "$BASE_BRANCH"
3648
env:
3749
GITHUB_TOKEN: ${{ inputs.github-token }}

.github/actions/clippy-annotation-reporter/src/main.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,13 +323,23 @@ fn analyze_annotations(
323323

324324
/// Get file content from a specific branch
325325
fn get_file_content(file: &str, branch: &str) -> Result<String> {
326+
println!("Attempting to get content of '{}' from branch '{}'", file, branch);
327+
326328
let output = Command::new("git")
327329
.args(["show", &format!("{}:{}", branch, file)])
328330
.output()
329-
.context("Failed to execute git show command")?;
331+
.context(format!("Failed to execute git show command for {}", file))?;
330332

331333
if !output.status.success() {
332334
let stderr = String::from_utf8_lossy(&output.stderr);
335+
println!("Git command error output: {}", stderr);
336+
337+
// Try alternative branch reference formats
338+
if !branch.starts_with("origin/") && !branch.starts_with("refs/") {
339+
println!("Trying with 'origin/' prefix...");
340+
return get_file_content(file, &format!("origin/{}", branch));
341+
}
342+
333343
anyhow::bail!("Git show command failed: {}", stderr);
334344
}
335345

0 commit comments

Comments
 (0)