package swhid_types

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type object_type =
  1. | 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)

    *)
  2. | Directory
  3. | Release
  4. | Revision
  5. | Snapshot

The kinds of objects represented by swhids, see the software heritage model documentation.

type object_id = string

Must be of length 40 and made only of hexadecimal characters.

type identifier_core = int * object_type * object_id

The scheme version, the object type and the object identifier.

type context_qualifier =
  1. | 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

    *)
  2. | Origin of string
    (*

    the software origin where an object has been found or observed in the wild, as an URI

    *)
  3. | 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

    *)
  4. | Visit of identifier_core
    (*

    the core identifier of a snapshot corresponding to a specific visit of a repository containing the designated object

    *)
type qualifier =
  1. | Context of context_qualifier
    (*

    either a context

    *)
  2. | Fragment of int * int option
    (*

    or a fragment (a line number or two)

    *)
type identifier = identifier_core * qualifier list

The type for full swhids.

val object_type_of_string : string -> object_type option

Helper to build an object_type from a string.

val object_id_invalid : object_id -> bool

Checks 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 option

Helper 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 -> identifier

Builds 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 -> identifier

Builds a swhid of kind directory from it's core id and a list of qualifiers.

val snapshot : object_id -> qualifier list -> identifier

Builds a swhid of kind snapshot from it's core id and a list of qualifiers

val revision : object_id -> qualifier list -> identifier

Builds a swhid of kind revision from it's core id and a list of qualifiers

val release : object_id -> qualifier list -> identifier

Builds a swhid of kind release from it's core id and a list of qualifiers

val get_object_id : identifier -> object_id

Extract the core id from a given identifier.

val get_object_type : identifier -> object_type

Extract the object type from a given identifier.

exception Parser_error of string

Exception raised by the parser when e.g. the scheme version is unknown.

OCaml

Innovation. Community. Security.