Exemplo n.º 1
0
 def metadata(self, default: str = None) -> Optional[str]:
     if concourse_context():
         return json.load(
             open(
                 os.path.join(self.path, ".git", "resource",
                              "metadata.json")))
     return default
Exemplo n.º 2
0
 def changed_files(self,
                   default: str = None) -> Union[List[str], Optional[str]]:
     if concourse_context():
         with open(
                 os.path.join(self.path, ".git", "resource",
                              "changed_files")) as f:
             lines = f.readlines()
             return [line.strip() for line in lines]
     return default
Exemplo n.º 3
0
 def __init__(self, name: str, uri: str, config: dict) -> None:
     self.name = name
     self.config = config
     self.uri = uri
     if concourse_context():
         self.path = os.path.abspath(self.name)
     else:
         self.path = os.getenv("HOME",
                               "") + "/workspace/" + os.path.splitext(
                                   os.path.basename(uri))[0]
Exemplo n.º 4
0
 def ref(self) -> str:
     if concourse_context():
         with open(os.path.join(self.path, ".git/ref")) as f:
             return f.read().strip()
     try:
         return self.tag()
     except Exception:
         return subprocess.check_output(
             ["git", "rev-parse", "HEAD"],
             cwd=self.path).decode("utf-8").strip()
Exemplo n.º 5
0
 def tag(self, default: str = None) -> Optional[str]:
     if concourse_context():
         with open(os.path.join(self.path, "tag")) as f:
             return f.read().strip()
     return default
Exemplo n.º 6
0
 def short_ref(self) -> str:
     if concourse_context():
         with open(os.path.join(self.path, ".git/short_ref")) as f:
             return f.read().strip()
     return subprocess.check_output(["git", "rev-parse", "--short", "HEAD"],
                                    cwd=self.path).decode("utf-8").strip()
Exemplo n.º 7
0
 def version(self) -> str:
     if concourse_context():
         with open(os.path.join(self.path, "version")) as f:
             return f.read().strip()
     return "0.0.1"
Exemplo n.º 8
0
 def digest(self) -> str:
     if concourse_context():
         with open(os.path.join(self.path, "digest")) as f:
             return f.read().strip()
     return "latest"