How Bit Versions Independent Components

Learn how Bit versions individual independent components using its own set of object types.

Eden Ella
Bits and Pieces

--

This article assumes basic prior knowledge of git’s internals and Bit.

Independent components are developed, versioned, and collaborated on in a Bit workspace. Each component starts its way as multiple source files which are then mapped to a single component id, configured, built, and finally tagged (along with the generated artifacts) with a new release version.

To learn more about the process an independent component goes through prior to it being tagged, see here:

The path of an independent component, from multiple source files to a set of shareable git-like objects. Much of the steps are autogenerated by Bit.

Component versioning: Generating Bit objects

$ bit tag <component-id> <version> --message "message"

Once a component has gone through its build process it is ready to be tagged with a new version. This is where Bit objects are generated from the component files, configurations, and artifacts. These objects are stored in Bit’s content-addressable storage, the ‘local scope’, which is placed in the workspace .bit or .git/bit directory.

Run the bit cat-scope command, in your workspace directory, to see all objects in your local scope.

Just like git objects, Bit objects are named with a SHA-1 hash. The output table shows the mapping between each component ID and its component-object hash.

Object types

Component

A component object stores general information about a component. That includes its component id, scope name, references to its version objects, and more. The component’s hash is not based on its content since it is not immutable. It is updated whenever a component gets tagged with a new release version.

Run bit cat-object -p <component-hash> to see the component object content.

Version/Snap

The Version/Snap object contains the following information:

  • The component file structure, with references to snapshots (blobs) of the component’s source files (this section resembles Git’s ‘tree’ objects).
  • References to snapshots (blobs) of the component’s artifacts (distributable code, package, etc.)
  • Metadata regarding the component’s dependencies and development environment setup (including various Bit extensions that are used by that component).
  • More information relating to other aspects of an independent component.

A version object (a “commit”) can be created without creating a reference to it, the version number, in the ‘component’ object. This is done by using bit snap <component-id> .

Run bit cat-object -p <version-hash> to see the content of a component version object.

Source

Source objects are snapshots of the component’s source code, compiled code, and other generated artifacts.

Let’s have a look at the content of the following file:

$ bit cat-object -p df4f3cf88950c744a22d9f5423d360c7346b8021

Putting it all together

The below diagram shows the .bitmap file referencing to specific component versions to be used by the working directory.

--

--