ts-playground
    Preparing search index...

    ObjectVersionControl class

    This class is a version control system for objects. Like Git, it stores snapshots and commits. It can hold multiple commits like Git, and it is also possible to merge between commits. Unlike Git,

    • it does not have concepts like trees. It manages versions of a single object.
    • it does not have a staging area
    • it does not have branches.
    • it does not have a working directory.
    • it does not have a remote repository. But it can push and pull commits and snapshots to another ObjectVersionControl instance.

    Type Parameters

    • T
    Index

    Methods

    • Checkout a commit Change the head to the given commit.

      Parameters

      • hash: string

        The hash of the commit

      Returns void

    • Commit a snapshot Commit the given data. The commit is derived from the current head.

      Parameters

      • data: T

        The data to commit

      Returns string

      The hash value of the commit

    • Create a commit with the given targets and data This method creates a commit with multiple parents. In most cases, it is easier to use the commit() method.

      Parameters

      • targets: string[]

        The hashes of the parent commits

      • data: T

        The data to commit

      Returns string

      The hash value of the commit

    • Get the data of a snapshot by its hash

      Parameters

      • hash: string

        The hash of the snapshot

      Returns T

      The data of the snapshot

    • Get the data of a snapshot by the commit hash

      Parameters

      • hash: string

        The hash of the commit

      Returns T

      The data of the snapshot

    • Get sync items between the target and the base

      Parameters

      • target: string

        Hash value of the target commit

      • base: null | string

        Hash value of the base commit

      Returns SyncItems<T>

      SyncItems {commits, snapshots}

    • Merge the targets with the resolver Merge multiple commits and commit the result. The failure of the merge is indicated by the Resolver throwing an exception.

      Parameters

      • targets: string[]

        The hashes of the commits to merge

      • mergeResolver: MergeResolver<T>

        The resolver to merge the commits

      Returns string

      The hash value of the commit