11import  *  as  debugLib  from  'debug' ; 
2+ import  *  as  pathLib  from  'path' ; 
23
34import  { 
45  EntityToFix , 
@@ -11,7 +12,7 @@ import { MissingRemediationDataError } from '../../../../lib/errors/missing-reme
1112import  {  MissingFileNameError  }  from  '../../../../lib/errors/missing-file-name' ; 
1213import  {  partitionByFixable  }  from  './is-supported' ; 
1314import  {  NoFixesCouldBeAppliedError  }  from  '../../../../lib/errors/no-fixes-applied' ; 
14- import  {  parseRequirementsFile  }  from  './update-dependencies/requirements-file-parser ' ; 
15+ import  {  extractProvenance  }  from  './extract-version-provenance ' ; 
1516
1617const  debug  =  debugLib ( 'snyk-fix:python:requirements.txt' ) ; 
1718
@@ -53,17 +54,19 @@ export async function fixIndividualRequirementsTxt(
5354  if  ( ! fileName )  { 
5455    throw  new  MissingFileNameError ( ) ; 
5556  } 
56-   const  requirementsTxt  =  await  entity . workspace . readFile ( fileName ) ; 
57-   const  requirementsData  =  parseRequirementsFile ( requirementsTxt ) ; 
58- 
57+   const  {  dir,  base }  =  pathLib . parse ( fileName ) ; 
58+   const  versionProvenance  =  await  extractProvenance ( 
59+     entity . workspace , 
60+     dir , 
61+     base , 
62+   ) ; 
5963  // TODO: allow handlers per fix type (later also strategies or combine with strategies) 
6064  const  {  updatedManifest,  changes }  =  updateDependencies ( 
61-     requirementsData , 
65+     versionProvenance [ base ] , 
6266    remediationData . pin , 
6367  ) ; 
6468
65-   // TODO: do this with the changes now that we only return new 
66-   if  ( updatedManifest  ===  requirementsTxt )  { 
69+   if  ( ! changes . length )  { 
6770    debug ( 'Manifest has not changed!' ) ; 
6871    throw  new  NoFixesCouldBeAppliedError ( ) ; 
6972  } 
0 commit comments