|
@ -15,17 +15,18 @@ Copy this file to .git/hooks/ |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
import os |
|
|
import os |
|
|
import sys |
|
|
|
|
|
import string |
|
|
|
|
|
import re |
|
|
import re |
|
|
|
|
|
|
|
|
|
|
|
import string |
|
|
|
|
|
import sys |
|
|
from subprocess import call, check_output |
|
|
from subprocess import call, check_output |
|
|
|
|
|
|
|
|
try: |
|
|
try: |
|
|
from urllib.parse import urlparse |
|
|
from urllib.parse import urlparse |
|
|
except ImportError: |
|
|
except ImportError: |
|
|
from urlparse import urlparse |
|
|
from urlparse import urlparse |
|
|
|
|
|
|
|
|
from fileinput import FileInput |
|
|
from fileinput import FileInput |
|
|
|
|
|
|
|
|
# https://github.com/python/cpython/commit/6cb7b659#diff-78790b53ff259619377058acd4f74672 |
|
|
# https://github.com/python/cpython/commit/6cb7b659#diff-78790b53ff259619377058acd4f74672 |
|
|
if sys.version_info[0] < 3: |
|
|
if sys.version_info[0] < 3: |
|
|
class FileInputCtx(FileInput): |
|
|
class FileInputCtx(FileInput): |
|
@ -35,6 +36,7 @@ if sys.version_info[0] < 3: |
|
|
def __exit__(self, type, value, traceback): |
|
|
def __exit__(self, type, value, traceback): |
|
|
self.close() |
|
|
self.close() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileInput = FileInputCtx |
|
|
FileInput = FileInputCtx |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -91,15 +93,15 @@ def espurna_get_version(base, version_h="code/espurna/config/version.h"): |
|
|
|
|
|
|
|
|
TEMPLATES = { |
|
|
TEMPLATES = { |
|
|
"![travis]": "[![travis](https://travis-ci.org/{USER}/{REPO}.svg?branch={BRANCH})]" |
|
|
"![travis]": "[![travis](https://travis-ci.org/{USER}/{REPO}.svg?branch={BRANCH})]" |
|
|
"(https://travis-ci.org/{USER}/{REPO})\n", |
|
|
|
|
|
"![version]": "[![version](https://img.shields.io/badge/version-{VERSION:escape_hyphen}-brightgreen.svg)](CHANGELOG.md)\n", |
|
|
|
|
|
|
|
|
"(https://travis-ci.org/{USER}/{REPO})\n", |
|
|
|
|
|
"![version]": "[![version](https://img.shields.io/badge/version-{VERSION:escape_hyphen}-brightgreen.svg)]" |
|
|
|
|
|
"(CHANGELOG.md)\n", |
|
|
"![branch]": "[![branch](https://img.shields.io/badge/branch-{BRANCH:escape_hyphen}-orange.svg)]" |
|
|
"![branch]": "[![branch](https://img.shields.io/badge/branch-{BRANCH:escape_hyphen}-orange.svg)]" |
|
|
"(https://github.com/{USER}/{REPO}/tree/{BRANCH}/)\n", |
|
|
|
|
|
|
|
|
"(https://github.com/{USER}/{REPO}/tree/{BRANCH}/)\n", |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
README = "README.md" |
|
|
README = "README.md" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
if __name__ == "__main__": |
|
|
base = os.getcwd() |
|
|
base = os.getcwd() |
|
|
|
|
|
|
|
@ -117,6 +119,7 @@ if __name__ == "__main__": |
|
|
for k, tmpl in TEMPLATES.items() |
|
|
for k, tmpl in TEMPLATES.items() |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def fmt_line(line): |
|
|
def fmt_line(line): |
|
|
for match, tmpl in templates: |
|
|
for match, tmpl in templates: |
|
|
if match in line: |
|
|
if match in line: |
|
@ -124,6 +127,7 @@ if __name__ == "__main__": |
|
|
|
|
|
|
|
|
return line |
|
|
return line |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
path = os.path.join(base, README) |
|
|
path = os.path.join(base, README) |
|
|
|
|
|
|
|
|
with FileInput(path, inplace=True) as readme: |
|
|
with FileInput(path, inplace=True) as readme: |
|
|