Skip to content

Commit

Permalink
omnicache conversion tweak (#268)
Browse files Browse the repository at this point in the history
* Add conversion test case for existence of old YAML configuration file
* Update validation routine to detect the presence of old config file
  • Loading branch information
joschock authored Aug 19, 2021
1 parent 34cd694 commit 076e630
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions edk2toolext/omnicache.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ def _ValidateOmnicache(self):
logging.debug("{0} error getting repo state - not valid (not convertible).".format(self.path))
return (False, False)
if (out.getvalue().strip().lower() == "true"):
if (os.path.exists(os.path.join(self.path, PRE_0_11_OMNICACHE_FILENAME))):
logging.debug("{0} - old config file present. not valid (is convertible).".format(self.path))
return (False, True)
out = StringIO()
ret = RunCmd("git", "config --local omnicache.metadata.version", workingdir=self.path, outstream=out)
if (ret != 0):
Expand Down
12 changes: 12 additions & 0 deletions edk2toolext/tests/test_omnicache.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,18 @@ def test_omnicache_convert(self):
assert(gitret == 0)
assert(out.getvalue().strip() == "")

# add an empty file to simulate the old config yaml, but leave metadata in place.
# this simulates the case where an old version of omnicache ran and updated the remotes
# with some non-UUID versions, but the metadata version still exists. In this case, conversion
# should be run to cleanup the remotes.
with open(os.path.join(testcache, omnicache.PRE_0_11_OMNICACHE_FILENAME), "w") as yf:
yf.write("Not A Real YAML File")

# confirm that _ValidateOmnicache correctly identifies cache state
(valid, convertible) = oc._ValidateOmnicache()
assert(not valid)
assert(convertible)

def test_omnicache_add_remove(self):
testcache = os.path.join(os.path.abspath(os.getcwd()), test_dir, "testcache")

Expand Down

0 comments on commit 076e630

Please sign in to comment.