extra-files: Write a metadata file enumerating extra files
Introduces a new metadata file to track arbitrary files added during the
extra-files phase. This file is placed in the root of each tree and is
called ``extra_files.json``. It is a JSON file containing a single
object, which contains a "header" key with an object describing the
metadata, and a "data" key, which is an array of objects, where each
object represents a file. Each object contains the "file", "checksums",
and "size" keys. "file" is the relative path from the tree root to the
extra file. "checksums" is an object containing one or more checksums,
where the key is the digest type and the value of that key is the hex
digest. Finally, the size is the size of the file in bytes.
For example:
{
"header": {"version": "1.0},
"data": [
{
"file": "GPL",
"checksums": {
"sha256": "8177f97513213526df2cf6184d8ff986c675afb514d4e68a404010521b880643"
},
"size": 18092
},
{
"file": "release-notes/notes.html",
"checksums": {
"sha256": "82b1ba8db522aadf101dca6404235fba179e559b95ea24ff39ee1e5d9a53bdcb"
},
"size": 1120
}
]
}
Signed-off-by: Jeremy Cline <jeremy@jcline.org>
Fixes: #295
This commit is contained in:
parent
6aeab9ee9d
commit
ee1ee0467b
9 changed files with 265 additions and 11 deletions
|
|
@ -379,5 +379,32 @@ class TestLevenshtein(unittest.TestCase):
|
|||
self.assertEqual(util.levenshtein('kitten', 'sitting'), 3)
|
||||
|
||||
|
||||
class TestRecursiveFileList(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.tmp_dir = tempfile.mkdtemp()
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.tmp_dir)
|
||||
|
||||
def test_flat_file_list(self):
|
||||
"""Build a directory containing files and assert they are listed."""
|
||||
expected_files = sorted(['file1', 'file2', 'file3'])
|
||||
for expected_file in [os.path.join(self.tmp_dir, f) for f in expected_files]:
|
||||
touch(expected_file)
|
||||
|
||||
actual_files = sorted(util.recursive_file_list(self.tmp_dir))
|
||||
self.assertEqual(expected_files, actual_files)
|
||||
|
||||
def test_nested_file_list(self):
|
||||
"""Build a directory containing files and assert they are listed."""
|
||||
expected_files = sorted(['file1', 'subdir/file2', 'sub/subdir/file3'])
|
||||
for expected_file in [os.path.join(self.tmp_dir, f) for f in expected_files]:
|
||||
touch(expected_file)
|
||||
|
||||
actual_files = sorted(util.recursive_file_list(self.tmp_dir))
|
||||
self.assertEqual(expected_files, actual_files)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue