Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 415434 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]
Current hook
pre-receive.gentoo-news (text/x-python), 2.06 KB, created by
Michał Górny
on 2015-10-25 10:59:59 UTC
(
hide
)
Description:
Current hook
Filename:
MIME Type:
Creator:
Michał Górny
Created:
2015-10-25 10:59:59 UTC
Size:
2.06 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> > >import datetime, os, re, subprocess, sys, fileinput > >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) > > >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 = filter(lambda x: x != 0, results) > if len(results) == 0: > return 0 > else: > print '%s: errors in commits' % (prog, ) > print ''.join(map(lambda x: x+"\n", 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 filter(lambda f: len(f) > 0, added): > # GLEP 42: name should take the form of: > # yyyy-mm-dd-<name>/yyyy-mm-dd-<name>.<lang>.txt[.asc] > # where <name>: [a-z0-9+_-]+, <lang>: [a-z][a-z] > > match = PATH_REGEX.match(filename) > if not match: > return 'Path syntax invalid: %s' % filename > date = [int(match.group(x)) for x in ('year', 'month', 'day')] > > try: > datetime.date(*date) > except ValueError: > return 'Date invalid: %s' % '-'.join(date) > > # 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