Skip to content

Add line diff tracking to PR line counter workflow#165

Merged
functionstackx merged 6 commits into
mainfrom
copilot/extend-line-counter-workflow
Nov 5, 2025
Merged

Add line diff tracking to PR line counter workflow#165
functionstackx merged 6 commits into
mainfrom
copilot/extend-line-counter-workflow

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 4, 2025

Extends the PR line counter workflow to calculate and display line changes between PR and base branches.

Changes

  • Line difference calculation: Fetch base branch, count lines in base version, compute diff (PR lines - base lines)
  • Enhanced output: Display base line count, line diff with directional indicators (📈 increase / 📉 decrease / ➡️ no change) in both GitHub summary and PR comments
  • New file handling: When file doesn't exist in base, show "0 (new file)" and full line count as positive diff
  • Concurrency safety: Use mktemp for temporary files to avoid conflicts in parallel workflow runs
  • Robust error handling: Explicit error checking for base branch fetch with clear error messages
  • Resource cleanup: Use trap to ensure temporary files are cleaned up even on unexpected exits

Example Output

Existing file modified:

**Total Lines:** 960
**Base Lines:** 956
**Change:** +4 lines 📈

New file added:

**Total Lines:** 100
**Base Lines:** 0 (new file)
**Change:** +100 lines 📈
Original prompt

This section details on the original issue you should resolve

<issue_title>line diff workflow CI</issue_title>
<issue_description>extend .github/workflows/pr-line-counter.yml github action CI such that it will print on github summary & comment the line number change also</issue_description>

Comments on the Issue (you are @copilot in this section)

  • Fixes InferenceMAX/InferenceMAX#164

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Extend line diff workflow CI to print summary and comment Add line diff tracking to PR line counter workflow Nov 4, 2025
Copilot AI requested a review from functionstackx November 4, 2025 23:03
@functionstackx functionstackx marked this pull request as ready for review November 4, 2025 23:03
@functionstackx functionstackx requested a review from a team as a code owner November 4, 2025 23:03
Copilot AI review requested due to automatic review settings November 4, 2025 23:03
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 4, 2025

📊 Line Count Report

File: utils/matrix-logic/generate_sweep_configs.py

Total Lines: 956

Base Lines: 956

Change: No change ➡️

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 4, 2025

📊 Line Count Report

File: utils/matrix-logic/generate_sweep_configs.py

Total Lines: 956

Base Lines: 956

Change: No change ➡️

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR extends the PR line counter workflow to track and display line differences between the PR branch and the base branch. It adds functionality to fetch the base branch version of the target file, calculate the difference in line counts, and display this information with visual indicators.

  • Adds base branch file fetching and line counting capability
  • Calculates and displays line differences with directional indicators (📈/📉/➡️)
  • Handles new files by showing "0 (new file)" for base count

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/pr-line-counter.yml Outdated
Comment on lines +44 to +45
BASE_FILE_TMP=$(mktemp)
if git show "origin/$BASE_REF:$TARGET_FILE" > "$BASE_FILE_TMP" 2>/dev/null; then
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The temporary file is created unconditionally but only cleaned up inside conditional branches. If the script exits unexpectedly between line 44 and the cleanup points (lines 53, 59), the temporary file will leak. Consider using a trap to ensure cleanup or move mktemp inside the conditional after verifying the file exists.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a trap to ensure the temporary file is cleaned up on exit, even if the script exits unexpectedly. The trap automatically handles cleanup, so the manual rm -f calls have been removed. Fixed in commit ab2df03.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 4, 2025

📊 Line Count Report

File: utils/matrix-logic/generate_sweep_configs.py

Total Lines: 956

Base Lines: 956

Change: No change ➡️

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 4, 2025

📊 Line Count Report

File: utils/matrix-logic/generate_sweep_configs.py

Total Lines: 956

Base Lines: 956

Change: No change ➡️

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 4, 2025

📊 Line Count Report

File: utils/matrix-logic/generate_sweep_configs.py

Total Lines: 956

Base Lines: 956

Change: No change ➡️

Copilot AI and others added 6 commits November 5, 2025 15:32
Co-authored-by: functionstackx <47992694+functionstackx@users.noreply.github.com>
Co-authored-by: functionstackx <47992694+functionstackx@users.noreply.github.com>
…dling

Co-authored-by: functionstackx <47992694+functionstackx@users.noreply.github.com>
Co-authored-by: functionstackx <47992694+functionstackx@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: functionstackx <47992694+functionstackx@users.noreply.github.com>
@functionstackx functionstackx force-pushed the copilot/extend-line-counter-workflow branch from ab2df03 to bfe7e97 Compare November 5, 2025 20:32
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 5, 2025

📊 Line Count Report

File: utils/matrix-logic/generate_sweep_configs.py

Total Lines: 956

Base Lines: 956

Change: No change ➡️

@functionstackx functionstackx merged commit e1e1a83 into main Nov 5, 2025
1 check passed
@functionstackx functionstackx deleted the copilot/extend-line-counter-workflow branch November 5, 2025 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

line diff workflow CI

3 participants