Skip to main content

Python-based Git Server

Project description

Overview

A git server implementation written in python.

Based off the amazing work by Stewart Park in this gist: https://gist.github.com/stewartpark/1b079dc0481c6213def9.

Features:

  • Makes any git repository lying below the search_paths setting available for git clone and git push via HTTP using basic authentication
  • Application defaults can be overridden by specifying a configuration file
    Review etc/config.yaml for a sample data structure.
  • On-demand repos: If you attempt to push a non-existing repo to the server, it will be created
  • Employs process threading via gunicorn

Installation

  • Install from pypi.org: pip install btgitserver
  • Install directly from git repo: pip install git+http://www.github.com/berttejeda/bert.git-server.git

Usage

To get usage information and help: bt.git-server -h

Clone paths

These are the routes accepted by the script:

  • '/<org_name>/<project_name>'

These routes mirror the directory structure under the git search path(s).

Authentication

For now, the only authentication available is HTTP AUTH BASIC

As such, the default credentials are:

Username: git-user Password: git-password

Usage Examples

Clone a repo

  • Create a test org and repo:
cd ~
mkdir -p /tmp/repos/contoso/test
cd /tmp/repos/contoso/test
git init .
git checkout -b main
touch test_file.txt
git add .
git commit -m 'Initial Commit'
cd ~
bt.git-server -r /tmp/repos

Note: The --repo-search-paths/-r cli option allows specifying multiple, space-delimited search paths, e.g. bt.git-server -r /tmp/repos /tmp/repos2

  • Launch the standalone git server

bt.git-server

You should see output similar to:

Running on http://0.0.0.0:5000/	
  • On client-side:

Try cloning the repo you just created via the supported routes:

e.g.

git clone http://git-user:git-password@127.0.0.1:5000/contoso/test

Push an on-demand repo

mkdir -p foo-bar
cd foo-bar
git init .
git remote add origin http://git-user:git-password@127.0.0.1:5000/contoso/foo-bar
git checkout -b main
touch test_file.txt
git add .
git commit -m 'Initial Commit'
git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)

Docker

For your convenience, a Dockerfile has been provided, so feel free to build your own containerized instance of this app, or use the pre-built docker image:

mkdir /tmp/repos
docker run -it --rm -p 5000:5000 \
-v /tmp/repos:/opt/git-server/repos \
berttejeda/git-server

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

btgitserver-3.2.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

btgitserver-3.2.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file btgitserver-3.2.0.tar.gz.

File metadata

  • Download URL: btgitserver-3.2.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for btgitserver-3.2.0.tar.gz
Algorithm Hash digest
SHA256 121e8645b2c99d98c638313e211e7147c8047cd159057f1cff5b14b6eb37a605
MD5 0021428cc13ab0f3f320c389f5c2a4f1
BLAKE2b-256 c527e40d5f08d23361de7b75a70fc8693f1ce5eea48ad926db5e52459a31ce7c

See more details on using hashes here.

File details

Details for the file btgitserver-3.2.0-py3-none-any.whl.

File metadata

  • Download URL: btgitserver-3.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for btgitserver-3.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 353eceee02748ded75d5e83d46dca5b19e0dca93841142f0331ca03621f9ae68
MD5 19f24cd416df4ebfaef3b6c151672e17
BLAKE2b-256 acae1a4ed3372142bf306214fcbb48933baf9983b4b3c91e38be55f33cee40e4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page