Add bugurl override, add projecturl override, add version filling for meson
This commit is contained in:
parent
1dfdcc73c0
commit
2fc6d63c90
|
@ -174,6 +174,9 @@ def heckimp(args: Sequence[str]):
|
|||
if 'donateurl' in inconfig:
|
||||
donateurl = inconfig['donateurl']
|
||||
|
||||
bugurl = inconfig['url']
|
||||
if 'bugurl' in inconfig:
|
||||
bugurl = inconfig['bugurl']
|
||||
|
||||
derivedconfig={
|
||||
# Derived variables from config
|
||||
|
@ -183,11 +186,14 @@ def heckimp(args: Sequence[str]):
|
|||
"filename": inconfig['name'].lower(),
|
||||
"ufilename": inconfig['name'].upper(),
|
||||
"backdomain": reverse_domain(inconfig['url']),
|
||||
# URLs
|
||||
"baseurl": inconfig['url'],
|
||||
"tutorialurl": tutorialurl,
|
||||
"docsurl": docsurl,
|
||||
"contriburl": contriburl,
|
||||
"donateurl": donateurl,
|
||||
"bugurl": bugurl,
|
||||
#
|
||||
"copyright": inconfig['copyright'],
|
||||
"version": inconfig['version'],
|
||||
"resource_path": reverse_domain(inconfig['url']).replace('.', '/'),
|
||||
|
@ -208,6 +214,13 @@ def heckimp(args: Sequence[str]):
|
|||
}
|
||||
sourceroot = Path(derivedconfig["sourcetree"])
|
||||
|
||||
visitfiles = set()
|
||||
seenfiles = set()
|
||||
targetpath = Path(derivedconfig["filename"])
|
||||
if targetpath.exists():
|
||||
visitfiles = set(targetpath.rglob('*'))
|
||||
|
||||
|
||||
# precompute string replacements
|
||||
for r in FILENAME_REGEXP:
|
||||
r.replacement = r.replacement.format(**derivedconfig)
|
||||
|
@ -243,6 +256,7 @@ def heckimp(args: Sequence[str]):
|
|||
continue
|
||||
# possibly rename file,
|
||||
outpath = Path(apply_regexps(FILENAME_REGEXP, [], str(path)))
|
||||
seenfiles.add(outpath)
|
||||
logger.info(f"processing {outpath}")
|
||||
# write each file to the outtreea
|
||||
if path.is_dir():
|
||||
|
@ -315,6 +329,11 @@ def heckimp(args: Sequence[str]):
|
|||
os.system('git add .')
|
||||
os.system(f"""git commit -m "Initial checkin of {derivedconfig['symname']} from {derivedconfig["us"]}" """)
|
||||
os.system(f"""git tag v{derivedconfig['version']}""")
|
||||
|
||||
leftovers = visitfiles - seenfiles
|
||||
if leftovers:
|
||||
# print them out but we need to think about filtercing them too (exclude .git and upstream-documentation)
|
||||
...
|
||||
print("Done.")
|
||||
return 0
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ CONTENTS_REGEXP: List[Replacement] = [
|
|||
r" * A derived work which may be trivial. However, any changes may be (C){year} by {copyright}\n *\n"
|
||||
r" * Original copyright, applying to most contents (license remains unchanged): ")
|
||||
),
|
||||
|
||||
R(re.compile(r"^(\W+)version: \'[0-9].*"), r"\1version: '{version}', #heckimp skip", 'meson.build'),
|
||||
R(
|
||||
re.compile(r'(.*)Spencer Kimball, Peter Mattis and the GIMP Development Team(.*)'),
|
||||
r"\1Based on work by Spencer Kimball, Peter Mattis and the GnuImp Development Team\2"
|
||||
|
@ -65,12 +65,14 @@ CONTENTS_REGEXP: List[Replacement] = [
|
|||
R(re.compile(r"(.*)https?://docs.gimp.org/(.*)"), r'\1{docsurl}\2'),
|
||||
R(re.compile(r"(.*)https?://www.gimp.org/develop(.*)"), r'\1{contriburl}\2'),
|
||||
R(re.compile(r"(.*)https?://www.gimp.org/donating(.*)"), r'\1{donateurl}\2'),
|
||||
|
||||
R(re.compile(r"(.*)https?://gitlab.gnome.org/GNOME/gimp/issues(.*)"), r'\1{bugurl}\2'),
|
||||
# override
|
||||
R(re.compile(r"project_url = 'https://gitlab.gnome.org/GNOME/gimp'"), r"project_url = '{baseurl}'"),
|
||||
R(re.compile(r"project_url_issues = project_url + '/issues/new'"), r"project_url_issues = '{bugurl}'"),
|
||||
# catchall urls
|
||||
R(re.compile(r"(.*)https?://www.gimp.org(.*)"), r'\1{baseurl}\2'),
|
||||
R(re.compile(r"(.*[ \t\"])(www.)?gimp.org(.*)"), r'\1{baseurl}\3'),
|
||||
|
||||
|
||||
## general replacements
|
||||
R(re.compile(r"(.*)gimp(.*)"), r'\1{filename}\2'),
|
||||
R(re.compile(r"(.*)GIMP(.*)"), r'\1{ufilename}\2'),
|
||||
|
@ -138,6 +140,8 @@ CONTENTS_EXCEPTIONS: List[re.Pattern] = [
|
|||
#re.compile(r".wiki.gimp.org.*"),
|
||||
re.compile(r".*irc.*gimp.org:6667.*"),
|
||||
re.compile(r".*meetthegimp.org.*"), # wtf this domain
|
||||
# these are pretty consistent notes in the code referring to upstream bugs.
|
||||
re.compile(r".*See[:]? https://gitlab.gnome.org/GNOME/gimp/.*")
|
||||
]
|
||||
|
||||
#
|
||||
|
|
|
@ -18,10 +18,12 @@ logger = logging.getLogger(__name__)
|
|||
# regex.match, we could make a function that configures the replacement based on a dictionary, we could
|
||||
# make a function that executes the replacement on a string, etc. It would probably make the below code
|
||||
# a bit less type dependent).
|
||||
# FIXME implement path limiting
|
||||
class Replacement:
|
||||
def __init__(self, regexp, replacement):
|
||||
def __init__(self, regexp, replacement, path=None):
|
||||
self.regexp = regexp
|
||||
self.replacement = replacement
|
||||
self.path = path
|
||||
|
||||
|
||||
def one_matches(relist: Sequence[Union[re.Pattern, Replacement, Sequence]], s: str) -> Union[None, re.Pattern, Replacement, Sequence]:
|
||||
|
|
Loading…
Reference in New Issue