Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7123339
D65.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Subscribers
None
D65.id.diff
View Options
diff --git a/swh/web/ui/backend.py b/swh/web/ui/backend.py
--- a/swh/web/ui/backend.py
+++ b/swh/web/ui/backend.py
@@ -166,6 +166,25 @@
return None
+def revision_get_multiple(sha1_git_bin_list):
+ """Return information about the revisions in sha1_git_bin_list
+
+ Args:
+ sha1_git_bin_list: The revisions' sha1s as a list of bytes.
+
+ Returns:
+ Revisions' information as an iterable of dicts if any found,
+ an empty list otherwise
+
+ Raises:
+ ValueError if the identifier provided is not of sha1 nature.
+ """
+ res = main.storage().revision_get(sha1_git_bin_list)
+ if res and len(res) >= 1:
+ return res
+ return []
+
+
def revision_log(sha1_git_bin, limit=100):
"""Return information about the revision with sha1 sha1_git_bin.
diff --git a/swh/web/ui/tests/test_backend.py b/swh/web/ui/tests/test_backend.py
--- a/swh/web/ui/tests/test_backend.py
+++ b/swh/web/ui/tests/test_backend.py
@@ -417,6 +417,92 @@
self.storage.revision_get.assert_called_with([sha1_bin])
@istest
+ def revision_get_multiple(self):
+ # given
+ sha1_bin = hashutil.hex_to_hash(
+ '18d8be353ed3480476f032475e7c233eff7371d5')
+ sha1_other = hashutil.hex_to_hash(
+ 'adc83b19e793491b1c6ea0fd8b46cd9f32e592fc')
+
+ stub_revisions = [
+ {
+ 'id': sha1_bin,
+ 'directory': hashutil.hex_to_hash(
+ '7834ef7e7c357ce2af928115c6c6a42b7e2a44e6'),
+ 'author': {
+ 'name': b'bill & boule',
+ 'email': b'bill@boule.org',
+ },
+ 'committer': {
+ 'name': b'boule & bill',
+ 'email': b'boule@bill.org',
+ },
+ 'message': b'elegant fix for bug 31415957',
+ 'date': datetime.datetime(2000, 1, 17, 11, 23, 54),
+ 'date_offset': 0,
+ 'committer_date': datetime.datetime(2000, 1, 17, 11, 23, 54),
+ 'committer_date_offset': 0,
+ 'synthetic': False,
+ 'type': 'git',
+ 'parents': [],
+ 'metadata': [],
+ },
+ {
+ 'id': sha1_other,
+ 'directory': hashutil.hex_to_hash(
+ '7834ef7e7c357ce2af928115c6c6a42b7e2a44e6'),
+ 'author': {
+ 'name': b'name',
+ 'email': b'name@surname.org',
+ },
+ 'committer': {
+ 'name': b'name',
+ 'email': b'name@surname.org',
+ },
+ 'message': b'ugly fix for bug 42',
+ 'date': datetime.datetime(2000, 1, 12, 5, 23, 54),
+ 'date_offset': 0,
+ 'committer_date': datetime.datetime(2000, 1, 12, 5, 23, 54),
+ 'committer_date_offset': 0,
+ 'synthetic': False,
+ 'type': 'git',
+ 'parents': [],
+ 'metadata': [],
+ }
+ ]
+ self.storage.revision_get = MagicMock(
+ return_value=stub_revisions)
+
+ # when
+ actual_revision = backend.revision_get_multiple([sha1_bin, sha1_other])
+
+ # then
+ self.assertEqual(actual_revision, stub_revisions)
+
+ self.storage.revision_get.assert_called_with(
+ [sha1_bin, sha1_other])
+
+ @istest
+ def revision_get_multiple_none_found(self):
+ # given
+ sha1_bin = hashutil.hex_to_hash(
+ '18d8be353ed3480476f032475e7c233eff7371d5')
+ sha1_other = hashutil.hex_to_hash(
+ 'adc83b19e793491b1c6ea0fd8b46cd9f32e592fc')
+
+ self.storage.revision_get = MagicMock(
+ return_value=[])
+
+ # when
+ actual_revision = backend.revision_get_multiple([sha1_bin, sha1_other])
+
+ # then
+ self.assertEqual(actual_revision, [])
+
+ self.storage.revision_get.assert_called_with(
+ [sha1_bin, sha1_other])
+
+ @istest
def revision_log(self):
# given
sha1_bin = hashutil.hex_to_hash(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 12:18 AM (3 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3223667
Attached To
D65: Open '/revision/<sha1>/prev/<sha1list>/log/' route
Event Timeline
Log In to Comment