Skip to content

Commit af2f6b0

Browse files
committed
fix: handle initial push with null SHA gracefully
1 parent c673516 commit af2f6b0

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ jobs:
2020
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2121
- name: Log output of the previous step
2222
run: |
23-
echo "This is the output of the previous step:"
23+
echo "This is the output of the previous step:"
2424
echo ${{ join( fromJSON( steps.changed-packages.outputs.packages ), ' ' ) }}

dist/index.js

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ import contains from '@stdlib/assert-contains';
2525
import { stripOffInternals, prunePackage } from './utils';
2626

2727

28+
// VARIABLES //
29+
30+
const NULL_SHA = '0000000000000000000000000000000000000000';
31+
32+
2833
// MAIN //
2934

3035
/**
@@ -54,6 +59,14 @@ async function main(): Promise<void> {
5459
default:
5560
setFailed( 'Unsupported event name: ' + context.eventName );
5661
}
62+
63+
// Handle initial push where there is no previous commit (null SHA):
64+
if ( base === NULL_SHA ) {
65+
debug( 'Initial push detected (null SHA). Returning empty packages list.' );
66+
setOutput( 'packages', [] );
67+
return;
68+
}
69+
5770
const response = await octokit.rest.repos.compareCommits({
5871
base,
5972
head,

0 commit comments

Comments
 (0)