From: Siddhesh Poyarekar Date: Thu, 16 Jan 2020 07:19:55 +0000 (+0530) Subject: vcs-to-changelog: Allow loading of custom quirks file X-Git-Tag: v1.0~4345 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=13ee6c5fa84486f5ae42d55e79eceb23426dfd81;p=thirdparty%2Fgnulib.git vcs-to-changelog: Allow loading of custom quirks file gnulib does not have a quirks file and if the scripts are not copied over to the project tree, it may never find the quirks file in the right place. Add a flag to vcs_to_changelog.py to allow one to specify the location of the quirks file instead. * build-aux/vcs_to_changelog.py: New commandline option -q. --- diff --git a/ChangeLog b/ChangeLog index b8578488ff..53e9d4ca2f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2020-01-16 Siddhesh Poyarekar + + vcs-to-changelog: Allow loading of custom quirks file. + * build-aux/vcs_to_changelog.py: New commandline option -q. + 2020-01-16 Siddhesh Poyarekar vcs-to-changelog: Fix formatting of ChangeLog output. diff --git a/build-aux/vcs_to_changelog.py b/build-aux/vcs_to_changelog.py index d5931e4e91..bf4bc7cf64 100755 --- a/build-aux/vcs_to_changelog.py +++ b/build-aux/vcs_to_changelog.py @@ -78,17 +78,8 @@ class ProjectQuirks: # header file that is only assembly code, which breaks the C parser. IGNORE_LIST = ['ChangeLog'] - -# Load quirks file. We assume that the script is run from the top level source -# directory. sys.path.append('/'.join([os.path.dirname(os.path.realpath(__file__)), 'vcstocl'])) -try: - from vcstocl_quirks import * - project_quirks = get_project_quirks(debug) -except: - project_quirks = ProjectQuirks() - def main(repo, frontends, refs): ''' ChangeLog Generator Entry Point. @@ -107,6 +98,9 @@ if __name__ == '__main__': parser.add_argument('-d', '--debug', required=False, action='store_true', help='Run the file parser debugger.') + parser.add_argument('-q', '--quirks', required=False, type=str, + help='Load a quirks file.') + args = parser.parse_args() debug.debug = args.debug @@ -115,6 +109,21 @@ if __name__ == '__main__': debug.eprint('Two refs needed to get a ChangeLog.') sys.exit(os.EX_USAGE) + # Load quirks file. We assume that the script is run from the top level source + # directory. + if args.quirks: + import importlib.util + spec = importlib.util.spec_from_file_location("vcstocl_quirks", args.quirks) + vcstocl_quirks = importlib.util.module_from_spec(spec) + spec.loader.exec_module(vcstocl_quirks) + project_quirks = vcstocl_quirks.get_project_quirks(debug) + else: + try: + from vcstocl_quirks import * + project_quirks = get_project_quirks(debug) + except: + project_quirks = ProjectQuirks() + REPO = {'git': GitRepo(project_quirks.IGNORE_LIST, debug)} fe_c = frontend_c.Frontend(project_quirks, debug)