Skip to content
Snippets Groups Projects
Commit 81863a53 authored by David Schäfer's avatar David Schäfer
Browse files

DmpFlagger: remove git dependency

parent 68dd21ad
No related branches found
No related tags found
2 merge requests!193Release 1.4,!188Release 1.4
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import subprocess
import json
from copy import deepcopy
from typing import TypeVar, Optional, List
......@@ -36,15 +35,13 @@ FLAGS = ["NIL", "OK", "DOUBTFUL", "BAD"]
class DmpFlagger(CategoricalFlagger):
def __init__(self, include_version=True):
def __init__(self, **kwargs):
super().__init__(FLAGS)
self.flags_fields = [FlagFields.FLAG, FlagFields.CAUSE, FlagFields.COMMENT]
self.extra_defaults = dict(cause=FLAGS[0], comment="")
version = subprocess.run(
"git describe --tags --always --dirty", shell=True, check=False, stdout=subprocess.PIPE,
).stdout
self.project_version = version.decode().strip() if include_version else ""
self.signature = ("flag", "comment", "cause", "force")
self._global_comments = kwargs
self._flags = None
self._causes = None
self._comments = None
......@@ -151,8 +148,8 @@ class DmpFlagger(CategoricalFlagger):
else:
flag = self.BAD if flag is None else flag
comment = json.dumps(
{"comment": comment,
"commit": self.project_version,
{**self._global_comments,
"comment": comment,
"test": kwargs.get("func_name", "")}
)
......@@ -240,7 +237,7 @@ class DmpFlagger(CategoricalFlagger):
def _construct_new(self, flags, causes, comments) -> DmpFlaggerT:
new = DmpFlagger()
new.project_version = self.project_version
new._global_comments = self._global_comments
new._flags = flags
new._causes = causes
new._comments = comments
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment