• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

adamws / kicad-git / d75dcee1-a2ab-4a47-bae7-146c9a0c1ed0

06 Mar 2024 07:52PM UTC coverage: 94.215% (+2.7%) from 91.525%
d75dcee1-a2ab-4a47-bae7-146c9a0c1ed0

push

circleci

adamws
Add KiCad 8 testing on linux

114 of 121 relevant lines covered (94.21%)

0.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.74
/source/git.py
1
import configparser
1✔
2
import os
1✔
3
import platform
1✔
4
import subprocess
1✔
5
from pathlib import Path
1✔
6
from typing import Optional
1✔
7

8
if platform.system() == "Darwin":
1✔
9
    DEFAULT_CONFIG = """[paths]
×
10
        git = /opt/homebrew/bin/git
11
        git_gui = /opt/homebrew/bin/git-citool"""
12
else:
13
    DEFAULT_CONFIG = """[paths]
1✔
14
        git = git
15
        git_gui = git citool"""
16

17
config = configparser.ConfigParser()
1✔
18
config.read_string(DEFAULT_CONFIG)
1✔
19
config.read(os.path.dirname(__file__) + "/config.ini")
1✔
20

21
git: str = config["paths"]["git"]
1✔
22
git_gui: str = config["paths"]["git_gui"]
1✔
23

24

25
def __run(command: str, cwd: Path) -> str:
1✔
26
    process = subprocess.Popen(
1✔
27
        git + " " + command,
28
        cwd=cwd,
29
        shell=True,
30
        stdout=subprocess.PIPE,
31
        stderr=subprocess.STDOUT,
32
        universal_newlines=True,
33
    )
34
    process.wait()
1✔
35
    output = ""
1✔
36
    if process.stdout:
1✔
37
        output = process.stdout.read()
1✔
38
    if process.returncode == 0:
1✔
39
        return output
1✔
40
    error = f"Error: Failed to '{git} {command}', received: {output}"
1✔
41
    raise RuntimeError(error)
1✔
42

43

44
def version() -> str:
1✔
45
    return __run("version", Path("."))
1✔
46

47

48
def toplevel(path: Path) -> Optional[Path]:
1✔
49
    if path.exists():
1✔
50
        try:
1✔
51
            result = __run("rev-parse --show-toplevel", path).strip()
1✔
52
            if result:
1✔
53
                return Path(result)
1✔
54
        except RuntimeError:
1✔
55
            pass
1✔
56
    return None
1✔
57

58

59
def citool(repo_dir: Path) -> None:
1✔
60
    subprocess.Popen(git_gui, cwd=repo_dir, shell=True)
×
61

62

63
__all__ = ["version", "toplevel", "citool"]
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc