Skip to content

Commit

Permalink
io.schema: Remove "repository" from "commit"
Browse files Browse the repository at this point in the history
Rename git_repository_commit* revision fields to git_commit*, in v3 I/O
schema.

Fixes kernelci#85.
  • Loading branch information
spbnick committed Jun 25, 2020
1 parent 68ac500 commit 8189aa6
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 12 deletions.
31 changes: 31 additions & 0 deletions kcidb/io/schema/test_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,34 @@ def test_origin(self):
)

self.assertEqual(VERSION.upgrade(prev_version_data), new_version_data)

def test_repository_commit_rename(self):
"""Check git_repository_commit* rename to git_commit* works"""
prev_version_data = dict(
version=dict(major=VERSION.previous.major,
minor=VERSION.previous.minor),
revisions=[
dict(id="origin1:5e29d1443c46b6ca70a4c940a67e8c09f05dcb7e",
git_repository_commit_hash="5e29d1443c46b6ca70a4c940a67e8c09f05dcb7e",
git_repository_commit_name="foo"),
dict(id="origin2:41f53451e75df9864a78c83e935e98ede7a170c2",
git_repository_commit_hash="41f53451e75df9864a78c83e935e98ede7a170c2",
git_repository_commit_name="bar"),
],
)
new_version_data = dict(
version=dict(major=VERSION.major,
minor=VERSION.minor),
revisions=[
dict(id="5e29d1443c46b6ca70a4c940a67e8c09f05dcb7e",
origin="origin1",
git_commit_hash="5e29d1443c46b6ca70a4c940a67e8c09f05dcb7e",
git_commit_name="foo"),
dict(id="41f53451e75df9864a78c83e935e98ede7a170c2",
origin="origin2",
git_commit_hash="41f53451e75df9864a78c83e935e98ede7a170c2",
git_commit_name="bar"),
],
)

self.assertEqual(VERSION.upgrade(prev_version_data), new_version_data)
20 changes: 13 additions & 7 deletions kcidb/io/schema/v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

# A regular expression pattern matching strings containing Git repository
# commit hash (sha1)
GIT_REPOSITORY_COMMIT_HASH_PATTERN = f"{SHA1_PATTERN}"
GIT_COMMIT_HASH_PATTERN = f"{SHA1_PATTERN}"

# A regular expression pattern matching strings containing revision IDs
REVISION_ID_PATTERN = \
f"{GIT_REPOSITORY_COMMIT_HASH_PATTERN}" \
f"{GIT_COMMIT_HASH_PATTERN}" \
f"(\\+{SHA256_PATTERN})?"

# A regular expression pattern matching strings containing origin name
Expand Down Expand Up @@ -139,14 +139,13 @@
"that's not available, the shortest possible git:// URL.",
"pattern": f"^{GIT_REPOSITORY_URL_PATTERN}$",
},
"git_repository_commit_hash": {
"git_commit_hash": {
"type": "string",
"description":
"The full commit hash of the revision's base code "
"in the Git repository",
"pattern": f"^{GIT_REPOSITORY_COMMIT_HASH_PATTERN}$",
"The full commit hash of the revision's base code",
"pattern": f"^{GIT_COMMIT_HASH_PATTERN}$",
},
"git_repository_commit_name": {
"git_commit_name": {
"type": "string",
"description":
"A human-readable name of the commit containing the base "
Expand Down Expand Up @@ -607,6 +606,13 @@ def remove_origin(id):
for build in data.get("builds", []):
build["revision_id"] = remove_origin(build["revision_id"])

# Rename git_repository_commit* to git_commit* in revisions
for revision in data.get("revisions", []):
for old, new in (("git_repository_commit_hash", "git_commit_hash"),
("git_repository_commit_name", "git_commit_name")):
if old in revision:
revision[new] = revision.pop(old)

# Update version
data['version'] = dict(major=JSON_VERSION_MAJOR,
minor=JSON_VERSION_MINOR)
Expand Down
2 changes: 1 addition & 1 deletion kcidb/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_min(self):
],
"discovery_time": "2020-03-02T15:16:15.790000+00:00",
"git_repository_branch": "wip/jgg-for-next",
"git_repository_commit_hash": "5e29d1443c46b6ca70a4c940a67e8c09f05dcb7e",
"git_commit_hash": "5e29d1443c46b6ca70a4c940a67e8c09f05dcb7e",
"git_repository_url": "git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git",
"misc": {
"pipeline_id": 467715
Expand Down
4 changes: 2 additions & 2 deletions kcidb/test_oo.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_revision(self):
],
"discovery_time": "2020-03-02T15:16:15.790000+00:00",
"git_repository_branch": "wip/jgg-for-next",
"git_repository_commit_hash": "5e29d1443c46b6ca70a4c940a67e8c09f05dcb7e",
"git_commit_hash": "5e29d1443c46b6ca70a4c940a67e8c09f05dcb7e",
"git_repository_url": "git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git",
"misc": {
"pipeline_id": 467715
Expand All @@ -93,7 +93,7 @@ def test_revision(self):
],
"discovery_time": "2020-03-02T15:16:15.790000+00:00",
"git_repository_branch": "wip/jgg-for-next",
"git_repository_commit_hash": "5e29d1443c46b6ca70a4c940a67e8c09f05dcb7e",
"git_commit_hash": "5e29d1443c46b6ca70a4c940a67e8c09f05dcb7e",
"git_repository_url": "git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git",
"misc": {
"pipeline_id": 467715
Expand Down
4 changes: 2 additions & 2 deletions kcidb/test_subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_min(self):
],
"discovery_time": "2020-03-02T15:16:15.790000+00:00",
"git_repository_branch": "wip/jgg-for-next",
"git_repository_commit_hash": "5e29d1443c46b6ca70a4c940a67e8c09f05dcb7e",
"git_commit_hash": "5e29d1443c46b6ca70a4c940a67e8c09f05dcb7e",
"git_repository_url": "git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git",
"misc": {
"pipeline_id": 467715
Expand All @@ -51,7 +51,7 @@ def test_min(self):
],
"discovery_time": "2020-03-02T15:16:15.790000+00:00",
"git_repository_branch": "wip/jgg-for-next",
"git_repository_commit_hash": "1254e88b4fc1470d152f494c3590bb6a33ab33eb",
"git_commit_hash": "1254e88b4fc1470d152f494c3590bb6a33ab33eb",
"git_repository_url": "git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git",
"misc": {
"pipeline_id": 467715
Expand Down

0 comments on commit 8189aa6

Please sign in to comment.