1+ #!/usr/bin/env python3
12import os
23import sys
34
67# Prepare the changelog for the new release
78# This function will extract the part of the changelog that
89# we want to include in the new release.
9- def extract_changelog_snippet (changelog_file , version_tag ):
10+ def extract_changelog_snippet (changelog_file ):
1011 output = ''
1112 if (not os .path .exists (changelog_file )):
1213 output = EMPTY_CHANGELOG
@@ -15,23 +16,20 @@ def extract_changelog_snippet(changelog_file, version_tag):
1516 with open (changelog_file , 'r' ) as f :
1617 lines = f .readlines ()
1718
18- # Include everything up to, but excluding the second heading
19+ # Include only the contents of the first section
1920 found_first_section = False
20- for i , line in enumerate ( lines ) :
21+ for line in lines :
2122 if line .startswith ('## ' ):
2223 if found_first_section :
2324 break
2425 found_first_section = True
25- output += line
26+ elif found_first_section :
27+ output += line
2628
27- output += f"See the full [CHANGELOG.md](https://github.com/github/codeql-action/blob/ { version_tag } /CHANGELOG.md) for more information."
29+ return output . strip ()
2830
29- return output
3031
31-
32- if len (sys .argv ) < 3 :
33- raise Exception ('Expecting argument: changelog_file version_tag' )
32+ if len (sys .argv ) < 2 :
33+ raise Exception ('Expecting argument: changelog_file' )
3434changelog_file = sys .argv [1 ]
35- version_tag = sys .argv [2 ]
36-
37- print (extract_changelog_snippet (changelog_file , version_tag ))
35+ print (extract_changelog_snippet (changelog_file ))
0 commit comments