Skip to content

Commit 3313c19

Browse files
committed
Problem: default starting_year of 2015 in projects
Solution: if a project is being just generated, and there is already an <include filename="license.xml"> in project.xml but no license.xml (verbatim) yet, create one with the content of <starting_year> (set to today's year) and a <license> tag with a reminder to define an actual license and regenerate. Do not touch existing project license files though. Signed-off-by: Jim Klimov <[email protected]>
1 parent 4b6c067 commit 3313c19

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

zproject.gsl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,30 @@ function resolve_includes (xml)
1717
if !defined (include.filename)
1818
abort "E: required attribute 'filename' not defined"
1919
endif
20+
if ("license.xml" = include.filename) & (!file.exists(include.filename))
21+
echo "W: license.xml included but not present; generating a new one with just a current starting_year and a reminder to word the license"
22+
# Assign HHMMSSss into my.time and YYYYMMDD into my.date:
23+
my.time = time.now(my.date)
24+
my.now_year = string.substr(my.date, 0, , 4)
25+
echo "W: detected current 'starting_year' as '$(my.now_year)'"
26+
my.outfile = file.open(include.filename, 'w')
27+
if (defined(my.outfile))
28+
file.write (my.outfile, "<starting_year>$(my.now_year)</starting_year>")
29+
file.write (my.outfile, "<license>")
30+
file.write (my.outfile, "LICENSE FOR THIS PROJECT IS NOT DEFINED!")
31+
file.write (my.outfile, "")
32+
file.write (my.outfile, "Copyright (C) $(my.now_year)- by $(project.name) Developers &lt;$(project.email)&gt;")
33+
file.write (my.outfile, "")
34+
file.write (my.outfile, "Please edit license.xml and populate the 'license' tag with proper")
35+
file.write (my.outfile, "copyright and legalese contents, and regenerate the zproject.")
36+
file.write (my.outfile, "")
37+
file.write (my.outfile, "LICENSE FOR THIS PROJECT IS NOT DEFINED!")
38+
file.write (my.outfile, "</license>")
39+
file.close (my.outfile)
40+
else
41+
abort "E: Could not create $(include.filename)"
42+
endif
43+
endif
2044
my.include_file = my.xml.load_file (filename)?
2145
if defined (my.include_file)
2246
move my.include_file after include

0 commit comments

Comments
 (0)