Skip to main content

gitlabfs

gitlabfs allows you to mount all projects in a company's GitLab instance as a file system.

About

This project was conceived out of a need to easily browse code in many different repositories within a company. While GitLab does have builtin browsing and search, it's just not as convenient to use as common tools like find and grep.

It sets out to solve that by exposing an entire GitLab instance as a file system with the following hierarchy:

/
  /user
    /project
      /master
        README.md
      /feature
        /abc
          /src
            main.py
      /v1.0
        main.py
  /group
    /subgroup
      /project

This allows you to freely browse all of the code in a GitLab instance without having to clone everything. All of the files are loaded from the GitLab API as you access them. The only caveat is that it is a read-only view.

Installation

Install the latest version of gitlabfs from PyPI:

pip install gitlabfs

Usage

  1. Go to your profile page in GitLab and generate a new access token with the api scope.

  2. Create a directory where you would like to access your projects from, e.g. ~/gitlab.

  3. Mount GitLab at that directory:

    glfs https://gitlab.mycompany.com ~/gitlab
    

You will be asked to provide your access token and then the GitLab hierarchy will be mounted.

Configuration

Various options can be passed to configure the properties of the file system:

  • --tags: Include tags in the list of repository refs.
  • --users: List user repositories as well.
  • --file-times: Better approximate file modification times with commit metadata.
  • --cache-expiry=SEC: Expire the cache after this many seconds (default: 60).
  • --fresh-project-tree: Enable cache expiry for the project tree.
  • --debug: Enable verbose logging for development purposes.

Many of these are not enabled by default because they may result in worse performance or more clutter.

The access token must be provided via a command line prompt by default, but can also be passed via the GITLAB_TOKEN environment variable.

Limitations

  • Not designed for GitLab instances with a huge number of projects (e.g. gitlab.com).
  • File modification times are not accurate since they are not exposed by the GitLab API.

Development

The file system can be easily run locally with Pipenv:

pipenv install
pipenv run ./glfs <url> <mountpoint> [options]

And the PyPI package is published using the following commands:

pipenv run python setup.py sdist bdist bdist_wheel
pipenv run twine upload dist/*

License

MIT License

Release files for gitlabfs 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gitlabfs 1.1.0
File Size Uploaded
gitlabfs-1.1.0.linux-x86_64.tar.gz 9.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gitlabfs 1.1.0
File Interpreter ABI Platform
gitlabfs-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.7 kB

Release files / gitlabfs-1.1.0.linux-x86_64.tar.gz

Download URL gitlabfs-1.1.0.linux-x86_64.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
28e86bcdf34e3095f736bc1065ae1ad7b034479bb657df0f503c21a34ebaec4b
BLAKE2b-256 checksum
How to use checksums
490a4dd3db4d38ed4d83dfac07575d41819597e94a82e57fdc566afbf12bcc96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release files / gitlabfs-1.1.0-py3-none-any.whl

Download URL gitlabfs-1.1.0-py3-none-any.whl
Size 12.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fbf7abdf5ec3ec3a065308f66a20c98c3799fe95ef8530a018693d8893943832
BLAKE2b-256 checksum
How to use checksums
f7a5d6494a15162a5202f7357e60baf77f1aa7ca9e11d55dcaae7daec07a05a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.5

2 release files

1.0.4

1 release file

1.0.3

1 release file

1.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page