Browse Source

Merge pull request #1455 from mcspr/version-badge

Escape hyphens in img.shields.io urls
refactor-terminal
Xose Pérez 6 years ago
committed by GitHub
parent
commit
7bde817adc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 8 deletions
  1. +1
    -1
      README.md
  2. +19
    -7
      pre-commit

+ 1
- 1
README.md View File

@ -3,7 +3,7 @@
ESPurna ("spark" in Catalan) is a custom firmware for ESP8285/ESP8266 based smart switches, lights and sensors.
It uses the Arduino Core for ESP8266 framework and a number of 3rd party libraries.
[![version](https://img.shields.io/badge/version-1.13.4-dev-brightgreen.svg)](CHANGELOG.md)
[![version](https://img.shields.io/badge/version-1.13.4--dev-brightgreen.svg)](CHANGELOG.md)
[![branch](https://img.shields.io/badge/branch-dev-orange.svg)](https://github.com/xoseperez/espurna/tree/dev/)
[![license](https://img.shields.io/github/license/xoseperez/espurna.svg)](LICENSE)
[![travis](https://travis-ci.org/xoseperez/espurna.svg?branch=dev)](https://travis-ci.org/xoseperez/espurna)


+ 19
- 7
pre-commit View File

@ -16,6 +16,7 @@ Copy this file to .git/hooks/
import os
import sys
import string
import re
from subprocess import call, check_output
@ -37,6 +38,14 @@ if sys.version_info[0] < 3:
FileInput = FileInputCtx
class CustomFormatter(string.Formatter):
def format_field(self, value, spec):
if spec == "escape_hyphen":
return value.replace("-", "--")
else:
return super(CustomFormatter, self).format_field(value, spec)
def run(cmd, cwd=None):
out = check_output(cmd, cwd=cwd)
out = out.decode("latin1").strip()
@ -79,12 +88,13 @@ def espurna_get_version(base, version_h="code/espurna/config/version.h"):
return version
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}-brightgreen.svg)](CHANGELOG.md)\n",
"![branch]": "[![branch](https://img.shields.io/badge/branch-{BRANCH}-orange.svg)]" \
"(https://github.com/{USER}/{REPO}/tree/{BRANCH}/)\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)]"
"(https://github.com/{USER}/{REPO}/tree/{BRANCH}/)\n",
}
README = "README.md"
@ -98,10 +108,12 @@ if __name__ == "__main__":
"USER": user,
"REPO": repo,
"BRANCH": git_branch(),
"VERSION": espurna_get_version(base)
"VERSION": espurna_get_version(base),
}
formatter = CustomFormatter()
templates = [
(k, tmpl.format(**fmt))
(k, formatter.format(tmpl, **fmt))
for k, tmpl in TEMPLATES.items()
]
@ -121,4 +133,4 @@ if __name__ == "__main__":
if call(["git", "add", README]):
sys.exit(1)
sys.exit(0);
sys.exit(0)

Loading…
Cancel
Save