@@ -181,6 +181,18 @@ export async function agentFix(
181181 packumentCache . clear ( )
182182 }
183183
184+ const getModifiedFiles = async ( cwd = process . cwd ( ) ) => {
185+ const unstagedCResult = await gitUnstagedModifiedFiles ( cwd )
186+ return unstagedCResult . ok
187+ ? unstagedCResult . data . filter ( filepath => {
188+ const basename = path . basename ( filepath )
189+ return (
190+ basename === 'package.json' || basename === pkgEnvDetails . lockName
191+ )
192+ } )
193+ : [ ]
194+ }
195+
184196 const handleInstallFail = ( ) : CResult < { fixed : boolean } > => {
185197 cleanupInfoEntriesLoop ( )
186198 return {
@@ -190,6 +202,10 @@ export async function agentFix(
190202 }
191203 }
192204
205+ const hasModifiedFiles = async ( cwd = process . cwd ( ) ) => {
206+ return ( await getModifiedFiles ( cwd ) ) . length > 0
207+ }
208+
193209 spinner ?. stop ( )
194210
195211 infoEntriesLoop: for (
@@ -393,20 +409,8 @@ export async function agentFix(
393409 )
394410
395411 // eslint-disable-next-line no-await-in-loop
396- const unstagedCResult = await gitUnstagedModifiedFiles ( cwd )
397- const moddedFilepaths = unstagedCResult . ok
398- ? unstagedCResult . data . filter ( filepath => {
399- const basename = path . basename ( filepath )
400- return (
401- basename === 'package.json' ||
402- basename === pkgEnvDetails . lockName
403- )
404- } )
405- : [ ]
406- if ( ! moddedFilepaths . length ) {
407- logger . warn (
408- 'Unexpected condition: Nothing to commit, skipping PR creation.' ,
409- )
412+ if ( ! ( await hasModifiedFiles ( cwd ) ) ) {
413+ debugFn ( 'notice' , 'skip: nothing to commit, skipping PR creation' )
410414 // Reset things just in case.
411415 if ( fixEnv . isCi ) {
412416 // eslint-disable-next-line no-await-in-loop
@@ -471,7 +475,8 @@ export async function agentFix(
471475 ! ( await gitCreateAndPushBranch (
472476 branch ,
473477 getSocketCommitMessage ( oldPurl , newVersion , workspace ) ,
474- moddedFilepaths ,
478+ // eslint-disable-next-line no-await-in-loop
479+ await getModifiedFiles ( cwd ) ,
475480 {
476481 cwd,
477482 email : fixEnv . gitEmail ,
0 commit comments