Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F25450607
gerrit.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
gerrit.py
View Options
# -------------------------------------------------------------
# Resolve hash :: VCS :: Gerrit
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# Description: Search hash on Gerrit
# License: BSD-2-Clause
# -------------------------------------------------------------
import
json
import
requests
def
query_gerrit_instance
(
instance
,
commit_hash
):
url
=
instance
+
"changes/?q="
+
commit_hash
r
=
requests
.
get
(
url
)
if
r
.
status_code
!=
200
:
print
(
r
.
status_code
)
return
None
# We can't use r.json() as currently the API starts responses
# by an extra line ")]}'"
payload
=
r
.
text
.
strip
()
.
split
(
"
\n
"
)[
-
1
]
result
=
json
.
loads
(
payload
)
if
not
result
:
return
None
change
=
result
[
0
]
return
f
"{instance}c/{change['project']}/+/{change['_number']}"
def
query_gerrit_instances
(
instances
,
commit_hash
):
for
instance
in
instances
:
url
=
query_gerrit_instance
(
instance
,
commit_hash
)
if
url
is
not
None
:
return
url
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Thu, Apr 16, 04:36 (9 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3621476
Default Alt Text
gerrit.py (1 KB)
Attached To
Mode
rRESOLVEHASH Resolve hash
Attached
Detach File
Event Timeline
Log In to Comment