5 class ProgramVersionDatabase:
7 Provides information on the versions of the OpenMPCD program.
14 This will require a file `.OpenMPCD/config/ProgramVersionDatabase.yaml`
15 to be readable, and contain in `repositoryPath` the path to the git
16 repository of the `OpenMPCD` project. The path may contain an initial '~'
17 character, which will be expanded to the user's home directory.
21 os.path.expanduser(
"~/.OpenMPCD/config/ProgramVersionDatabase.yaml")
23 config = yaml.safe_load(open(configPath,
"r"))
25 repoPath = os.path.expanduser(config[
"repositoryPath"])
30 1:
"ee7ec551c6f6d038d2a1195f35e4da8264f7f8e5",
31 8:
"62e287cb9d60906bf4b514291f42fc882d2d4f90",
32 15:
"9daa26741fb622759b4b32bef542441b693c7e22",
33 18:
"28b668cdf97e4a478c31bd17702bfacfddd2ed07",
34 19:
"53af091fd877cb52dcbe150aeaa5a8e03ebb67ca",
40 Returns the current commit SHA1 id, with the string "+MODIFICATIONS"
41 appended if any of the currently tracked files have been modified, and
42 with the string "+UNTRACKED" appended if there are files which are not
46 modificationsString =
"+MODIFICATIONS"
47 untrackedString =
"+UNTRACKED"
51 describe_strategy = pygit2.GIT_DESCRIBE_ALL,
52 abbreviated_size = 100,
53 dirty_suffix = modificationsString)
58 if description.endswith(modificationsString):
60 description = description[:-len(modificationsString)]
62 commit = str(self.
repository.revparse_single(description).id)
66 ret += modificationsString
68 for path, flags
in self.
repository.status().items():
69 if flags & pygit2.GIT_STATUS_WT_NEW:
71 ret += untrackedString
79 Returns whether the specified `commit` contains no known bugs.
82 for bugID, fixingCommit
in self.
knownBugs.items():
83 if fixingCommit
is None:
94 Returns whether the current commit contains no known bugs.
96 Untracked and unstaged changes are ignored for this function.
102 def _getCurrentGitCommit(self):
104 Returns the commit ID of the current commit.
106 Untracked and unstaged changes have no influence on the returned value.
111 describe_strategy = pygit2.GIT_DESCRIBE_ALL,
112 abbreviated_size = 100)
114 return self.
repository.revparse_single(description).id
117 def _gitCommitAContainsCommitB(self, commitA, commitB):
119 Returns whether the commit specified in `commitA` contains in its
120 history the commit specified in `commitB`.
123 if not isinstance(commitB, pygit2.Oid):
124 commitB = pygit2.Oid(hex = commitB)
127 if commit.id == commitB:
133 def _currentCommitContainsCommitB(self, commitB):
135 Returns whether the current commit conatins in its history `commitB`.