Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 415566 Details for
Bug 563814
gentoo news pre-receive hook is obtuse
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
updated hook
pre-receive.gentoo-news (text/x-python), 2.37 KB, created by
SpanKY
on 2015-10-27 01:44:41 UTC
(
hide
)
Description:
updated hook
Filename:
MIME Type:
Creator:
SpanKY
Created:
2015-10-27 01:44:41 UTC
Size:
2.37 KB
patch
obsolete
>#!/usr/bin/env python2 ># vim:fileencoding=utf-8 et st=4 sts=4 ># Copyright 2012-2014 Gentoo Foundation ># Distributed under the terms of the GNU General Public License v2 ># $Id$ > ># Author: MichaŠGórny <mgorny@gentoo.org> ># Author: Robin H. Johnson <robbat2@gentoo.org> (hook fixups) ># Based on work of: Ulrich Müller <ulm@gentoo.org> > >"""pre-receive git commit hook for gentoo news repo""" > >from __future__ import print_function > >import datetime >import fileinput >import os >import re >import subprocess >import sys > > ># GLEP 42: name should take the form of: ># where <name>: [a-z0-9+_-]+, <lang>: [a-z][a-z] ># yyyy-mm-dd-<name>/yyyy-mm-dd-<name>.<lang>.txt[.asc] >PATH_REGEX = re.compile(r''' >(?P<year> \d{4}) - (?P<month> \d{2}) - (?P<day> \d{2}) > - (?P<name> [a-z0-9+_-]+) / >(?P=year) - (?P=month) - (?P=day) - (?P=name) > . (?P<lang> [a-z]{2}) .txt (?: .asc )? >''', re.VERBOSE) > >INVALID_PATH_MSG = '''Path syntax invalid: %(filename)s >GLEP 42 paths must match: > yyyy-mm-dd-<name>/yyyy-mm-dd-<name>.<lang>.txt[.asc] > <name> is [a-z0-9+_-]+ > <lang> is [a-z][a-z] >''' > >INVALID_DATE_MSG = '''Date invalid: %(date)s: %(error)s''' > > >def main(prog, *argv): > if 'GIT_DIR' not in os.environ: > return '%s: GIT_DIR unset' % (prog, ) > results = [] > for line in fileinput.input(): > # <old-value> SP <new-value> SP <ref-name> LF > (oldrev, newrev, refname) = line.split() > results += [validate(oldrev, newrev, refname)] > results = [x for x in results if x] > if not results: > return 0 > else: > print('%s: errors in commits' % (prog, )) > print('\n'.join(results)) > return 1 > > >def validate(oldrev, newrev, _refname): > proc = subprocess.Popen( > ['git', 'diff', > '--name-only', '--diff-filter=A', > '%s..%s' % (oldrev, newrev)], > stdout=subprocess.PIPE) > added = proc.communicate()[0].rstrip().split('\n') > > for filename in [x for x in added if x]: > match = PATH_REGEX.match(filename) > if not match: > return INVALID_PATH_MSG % {'filename': filename} > date = [int(match.group(x)) for x in ('year', 'month', 'day')] > > try: > datetime.date(*date) > except ValueError as e: > return INVALID_DATE_MSG % {'date': date, 'error': e} > > # return nothing if good > return 0 > > >if __name__ == '__main__': > sys.exit(main(*sys.argv))
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 563814
:
415434
| 415566