Swhid_typestype object_type = | Content of string | (* The string parameter is the hash function name used for the computation, defaults to "sha1_git" (in most cases, you don't care about it) *) |
| Directory | |
| Release | |
| Revision | |
| Snapshot |
The kinds of objects represented by swhids, see the software heritage model documentation.
type identifier_core = int * object_type * object_idThe scheme version, the object type and the object identifier.
type context_qualifier = | Anchor of identifier_core | (* a designated node in the Merkle DAG relative to which a path to the object is specified, as the core identifier of a directory, a revision, a release or a snapshot *) |
| Origin of string | (* the software origin where an object has been found or observed in the wild, as an URI *) |
| Path of string | (* the absolute file path, from the root directory associated to the anchor node, to the object; when the anchor denotes a directory or a revision, and almost always when it’s a release, the root directory is uniquely determined; when the anchor denotes a snapshot, the root directory is the one pointed to by HEAD (possibly indirectly), and undefined if such a reference is missing *) |
| Visit of identifier_core | (* the core identifier of a snapshot corresponding to a specific visit of a repository containing the designated object *) |
type qualifier = | Context of context_qualifier | (* either a context *) |
| Fragment of int * int option | (* or a fragment (a line number or two) *) |
type identifier = identifier_core * qualifier listThe type for full swhids.
val object_type_of_string : string -> object_type optionHelper to build an object_type from a string.
val object_id_invalid : object_id -> boolChecks if an object_id is invalid, i.e. if it's not of length 40 or if it contains non-hexadecimal characters.
val object_id_from_string : string -> object_id optionHelper function to build an object_id from a string that will return None if the string isn't valid according to object_type_is_invalid
val content : ?hash_type:string -> object_id -> qualifier list -> identifierBuilds a swhid of kind content from it's core id and a list of qualifiers. The given hash defaults to "sha1_git" and you shouldn't care about it in most cases.
val directory : object_id -> qualifier list -> identifierBuilds a swhid of kind directory from it's core id and a list of qualifiers.
val snapshot : object_id -> qualifier list -> identifierBuilds a swhid of kind snapshot from it's core id and a list of qualifiers
val revision : object_id -> qualifier list -> identifierBuilds a swhid of kind revision from it's core id and a list of qualifiers
val release : object_id -> qualifier list -> identifierBuilds a swhid of kind release from it's core id and a list of qualifiers
val get_object_id : identifier -> object_idExtract the core id from a given identifier.
val get_object_type : identifier -> object_typeExtract the object type from a given identifier.