diff --git a/src/action.ts b/src/action.ts index cd92e8c..25c6a23 100644 --- a/src/action.ts +++ b/src/action.ts @@ -200,14 +200,24 @@ export function run(): void { baseRevision = mergeBase; } } catch (err: unknown) { - if (err instanceof Error) { - console.error('Error finding merge base:', err.message); + // If origin/baseRef fails, try just baseRef + try { + const mergeBase = execSync(`git merge-base "${baseRef}" HEAD`).toString().trim(); + if (mergeBase) { + baseRevision = mergeBase; + } + } catch { + if (err instanceof Error) { + console.error('Error finding merge base:', err.message); + } } } // Check if lockfile changed try { - const diff = execSync(`git diff --name-only "${baseRevision}" HEAD`, { + const diffCommand = `git diff --name-only "${baseRevision}" HEAD`; + core.debug(`Running diff command: ${diffCommand}`); + const diff = execSync(diffCommand, { maxBuffer: 50 * 1024 * 1024, }).toString(); const changedFiles = diff @@ -250,11 +260,16 @@ export function run(): void { // Get base version of lockfile let baseContent = '{}'; try { - baseContent = execSync(`git show "${baseRevision}:${lockfilePath}"`, { + const showCommand = `git show "${baseRevision}:${lockfilePath}"`; + core.debug(`Running show command: ${showCommand}`); + baseContent = execSync(showCommand, { stdio: ['pipe', 'pipe', 'ignore'], maxBuffer: 50 * 1024 * 1024, }).toString(); - } catch { + } catch (err: unknown) { + if (err instanceof Error) { + core.debug(`Error running git show: ${err.message}`); + } // If it fails, baseContent remains '{}' // This could happen if the file didn't exist in the base branch }