Skip to content
Snippets Groups Projects
Commit 02464c67 authored by Jenkins for Software Heritage's avatar Jenkins for Software Heritage
Browse files

New upstream version 0.0.67

parents d9ff8938 d52549f3
No related branches found
No related tags found
No related merge requests found
Metadata-Version: 2.1
Name: swh.model
Version: 0.0.66
Version: 0.0.67
Summary: Software Heritage data model
Home-page: https://forge.softwareheritage.org/diffusion/DMOD/
Author: Software Heritage developers
......
Metadata-Version: 2.1
Name: swh.model
Version: 0.0.66
Version: 0.0.67
Summary: Software Heritage data model
Home-page: https://forge.softwareheritage.org/diffusion/DMOD/
Author: Software Heritage developers
......
......@@ -37,7 +37,7 @@ class PidParamType(click.ParamType):
pids.parse_persistent_identifier(value)
return value # return as string, as we need just that
except ValidationError as e:
self.fail("%s is not a valid PID. %s." % (value, e), param, ctx)
self.fail("%s is not a valid SWHID. %s." % (value, e), param, ctx)
def pid_of_file(path):
......@@ -155,20 +155,22 @@ def identify_object(obj_type, follow_symlinks, obj):
@click.option(
"--verify",
"-v",
metavar="PID",
metavar="SWHID",
type=PidParamType(),
help="reference identifier to be compared with computed one",
)
@click.argument("objects", nargs=-1)
@click.argument("objects", nargs=-1, required=True)
def identify(obj_type, verify, show_filename, follow_symlinks, objects):
"""Compute the Software Heritage persistent identifier (PID) for the given
"""Compute the Software Heritage persistent identifier (SWHID) for the given
source code object(s).
For more details about Software Heritage PIDs see:
For more details about SWHIDs see:
\b
https://docs.softwareheritage.org/devel/swh-model/persistent-identifiers.html
Tip: you can pass "-" to identify the content of standard input.
\b
Examples:
......@@ -188,8 +190,6 @@ def identify(obj_type, verify, show_filename, follow_symlinks, objects):
swh:1:snp:510aa88bdc517345d258c1fc2babcd0e1f905e93 helloworld.git
""" # NoQA # overlong lines in shell examples are fine
if not objects:
objects = ["-"]
if verify and len(objects) != 1:
raise click.BadParameter("verification requires a single object")
......@@ -199,10 +199,10 @@ def identify(obj_type, verify, show_filename, follow_symlinks, objects):
if verify:
pid = next(results)[1]
if verify == pid:
click.echo("PID match: %s" % pid)
click.echo("SWHID match: %s" % pid)
sys.exit(0)
else:
click.echo("PID mismatch: %s != %s" % (verify, pid))
click.echo("SWHID mismatch: %s != %s" % (verify, pid))
sys.exit(1)
else:
for (obj, pid) in results:
......
......@@ -743,11 +743,7 @@ class PersistentId(_PersistentId):
def persistent_identifier(object_type, object_id, scheme_version=1, metadata={}):
"""Compute persistent identifier (stable over time) as per
documentation.
Documentation:
https://docs.softwareheritage.org/devel/swh-model/persistent-identifiers.html # noqa
"""Compute :ref:`SWHID <persistent-identifiers>` persistent identifiers.
Args:
object_type (str): object's type, either 'content', 'directory',
......@@ -776,7 +772,7 @@ def persistent_identifier(object_type, object_id, scheme_version=1, metadata={})
def parse_persistent_identifier(persistent_id):
"""Parse swh's :ref:`persistent-identifiers` scheme.
"""Parse :ref:`SWHID <persistent-identifiers>` persistent identifiers.
Args:
persistent_id (str): A persistent identifier
......
......@@ -26,6 +26,10 @@ class TestIdentify(DataMixin, unittest.TestCase):
self.assertEqual(result.exit_code, 0)
self.assertEqual(result.output.split()[0], pid)
def test_no_args(self):
result = self.runner.invoke(cli.identify)
self.assertNotEqual(result.exit_code, 0)
def test_content_id(self):
"""identify file content"""
self.make_contents(self.tmpdir_name)
......@@ -38,7 +42,7 @@ class TestIdentify(DataMixin, unittest.TestCase):
"""identify file content"""
self.make_contents(self.tmpdir_name)
for _, content in self.contents.items():
result = self.runner.invoke(cli.identify, input=content["data"])
result = self.runner.invoke(cli.identify, ["-"], input=content["data"])
self.assertPidOK(result, "swh:1:cnt:" + hash_to_hex(content["sha1_git"]))
def test_directory_id(self):
......
v0.0.66-0-g401bc17
\ No newline at end of file
v0.0.67-0-gd52549f
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment