package swhid
Library
Module
Module type
Parameter
Class
Class type
This module provides various functions to compute the swhid of a given object. Supported objects are content
, directory
, release
, revision
and snapshot
. The origins and visits objects are not supported. To learn more about the different object types and identifiers see the software heritage documentation.
type directory_entry = {
typ : string;
(*e.g. "file", "dir" or "rev"
*)permissions : int;
name : string;
target : Lang.object_id;
}
The type for directory entries list, needed to compute directories identifiers.
The type for dates, needed to compute releases and revisions identifiers.
val content_identifier : string -> Lang.identifier option
content_identifier s
computes the swhid for the s
content. s
is the raw content of a file as a string
.
E.g. content_identifier "_build\n"
is the swhid of this library's .gitignore
file.
val directory_identifier : directory_entry list -> Lang.identifier option
directory_identifier entries
compute the swhid for the entries
directory. entries
is a list of Lang.directory_entry
where each element points to another object (usually a file content or a sub-directory).
E.g. directory_identifier [ { typ = "file"
; permissions = 33188
; name = "README"
; target = "37ec8ea2110c0b7a32fbb0e872f6e7debbf95e21"
}]
is the swhid of a directory which has a single file README
with permissions 33188 and whose core identifier from content_identifier
is 37ec8ea2110c0b7a32fbb0e872f6e7debbf95e21
.
val release_identifier :
Lang.object_id ->
Lang.object_type ->
string ->
author:string option ->
date option ->
message:string option ->
Lang.identifier option
release_identifier target target_type name ~author date ~message
computes the swhid for a release object poiting to an object of type target_type
whose identifier is target
, the release having name name
, author ~author
and has been published on date
with the release message ~message
.
val revision_identifier :
Lang.object_id ->
Lang.object_id list ->
author:string ->
author_date:date option ->
committer:string ->
committer_date:date option ->
(string * string) array ->
string option ->
Lang.identifier option
revision dir parents ~author ~author_date ~committer ~committer_date extra_headers message
computes the swhid for a revision object whose directory has id dir
and whose parents has ids parents
which was authored by ~author
on ~author_date
and committed by ~committer
on ~committer_date
with extra headers extra_headers
and message message
.
val snapshot_identifier :
(string * (string * string) option) list ->
Lang.identifier option
snapshot_identifier branches
computes the swhid of the snapshot made of branches branches
where branches
is a list of branch elements. Each branch is of the form name, target
where name
is the name of the branch and where target
is a pair made of the identifier of the branch and its type.