refactor template parsing logic

Move the logic for selecting a license template based on user input into
a standalone func (fetchTemplate), and add test cases for all code
paths.

Delay parsing predefined license templates. This allows the new
fetchTemplate method to modify these templates before returning in the
future (to add SPDX license information).  Add tests to ensure that
these templates must always parse properly.

Rename copyrightData type to licenseData, since we will soon begin to
add more than just copyright data here (SPDX ID).

Rename prefix func to executeTemplate, since this better describes what
the function is doing.

These are all refactoring and cleanup changes; no behavioral changes.
This commit is contained in:
Will Norris
2021-07-26 17:29:53 -07:00
parent 6d92264d71
commit c2fdf83882
4 changed files with 168 additions and 48 deletions

3
testdata/custom.tpl vendored Normal file
View File

@@ -0,0 +1,3 @@
Copyright {{.Year}} {{.Holder}}
Custom License Template