@@ -786,7 +786,18 @@ def build_workflow(opts, retval):
786786 boilerplate = retval ['workflow' ].visit_desc ()
787787
788788 if boilerplate :
789- (logs_path / 'CITATION.md' ).write_text (boilerplate )
789+ # To please git-annex users and also to guarantee consistency
790+ # among different renderings of the same file, first remove any
791+ # existing one
792+ citation_files = {
793+ ext : logs_path / ('CITATION.%s' % ext )
794+ for ext in ('bib' , 'tex' , 'md' , 'html' )
795+ }
796+ for citation_file in citation_files .values ():
797+ if citation_file .exists () or citation_file .is_symlink ():
798+ citation_file .unlink ()
799+
800+ citation_files ['md' ].write_text (boilerplate )
790801 logger .log (25 , 'Works derived from this fMRIPrep execution should '
791802 'include the following boilerplate:\n \n %s' , boilerplate )
792803
@@ -795,8 +806,8 @@ def build_workflow(opts, retval):
795806 pkgrf ('fmriprep' , 'data/boilerplate.bib' ),
796807 '--filter' , 'pandoc-citeproc' ,
797808 '--metadata' , 'pagetitle="fMRIPrep citation boilerplate"' ,
798- str (logs_path / 'CITATION. md' ),
799- '-o' , str (logs_path / 'CITATION. html' )]
809+ str (citation_files [ ' md'] ),
810+ '-o' , str (citation_files [ ' html'] )]
800811 try :
801812 check_call (cmd , timeout = 10 )
802813 except (FileNotFoundError , CalledProcessError , TimeoutExpired ):
@@ -806,16 +817,16 @@ def build_workflow(opts, retval):
806817 # Generate LaTex file resolving citations
807818 cmd = ['pandoc' , '-s' , '--bibliography' ,
808819 pkgrf ('fmriprep' , 'data/boilerplate.bib' ),
809- '--natbib' , str (logs_path / 'CITATION. md' ),
810- '-o' , str (logs_path / 'CITATION. tex' )]
820+ '--natbib' , str (citation_files [ ' md'] ),
821+ '-o' , str (citation_files [ ' tex'] )]
811822 try :
812823 check_call (cmd , timeout = 10 )
813824 except (FileNotFoundError , CalledProcessError , TimeoutExpired ):
814825 logger .warning ('Could not generate CITATION.tex file:\n %s' ,
815826 ' ' .join (cmd ))
816827 else :
817828 copyfile (pkgrf ('fmriprep' , 'data/boilerplate.bib' ),
818- ( logs_path / 'CITATION. bib') )
829+ citation_files [ ' bib'] )
819830
820831 return retval
821832
0 commit comments