@adobe/git-server
serve a git repository over http(s)
Last updated 13 days ago by adobe-admin .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @adobe/git-server 
SYNC missed versions from official npm registry.

git-server

Status

codecov CircleCI GitHub license GitHub issues Renovate Language grade: JavaScript semantic-release

Description

git-server serves a hierarchy of local Git repositories to Git clients accessing the repository over http:// and https:// protocol.

git-server expects the local Git repositories (either cloned or created with git init) to be organized as follows in the local file system:

<repos_root_dir>/
├── <owner_1>/
│   └── <repo_1>
│   └── <repo_2>
├── <owner_2>/
│   └── <repo_1>
│   └── <repo_2>

Alternatively, a virtual repository mapping allows to 'mount' repositories independent of their location in the file system into a <owner>/<repo> hierarchy. A configuration example:

  virtualRepos: {
    owner1: {
      repo1: {
        path: './repo1',
      },
    },
    owner2: {
      repo2: {
        path: '/repos/repo2',
      },
    },
  },

Repositories exposed via git-server can be used just like any repository hosted on GitHub, i.e. you can clone them and push changes to. The repository contents can be accessed with the same url patterns you would use to request files managed on GitHub.

The following protocols and APIs are currently supported:

Installation

cd <checkout dir>
npm install

Getting started

git-server is configured via the config.js file which is expected to exist in the current working directory. Here's the default configuration:

{
  appTitle: 'Helix Git Server',
  repoRoot: './repos',
  // repository mapping. allows to 'mount' repositories outside the 'repoRoot' structure.
  virtualRepos: {
    demoOwner: {
      demoRepo: {
        path: './virtual/example',
      },
    },
  },
  listen: {
    http: {
      port: 5000,
      host: '0.0.0.0',
    },
    /*
    // https is optional
    https: {
      // cert: if no file is specfied a selfsigned certificate will be generated on-the-fly
      // cert: './localhost.crt',
      // key: if no file is specfied a key will be generated on-the-fly
      // key: './localhost.key',
      port: 5443,
      host: '0.0.0.0',
    },
    */
  },
  subdomainMapping: {
    // if enabled, <subdomain>.<baseDomain>/foo/bar/baz will be
    // resolved/mapped to 127.0.0.1/<subdomain>/foo/bar/baz
    enable: true,
    baseDomains: [
      // some wildcarded DNS domains resolving to 127.0.0.1
      'localtest.me',
      'lvh.me',
      'vcap.me',
      'lacolhost.com',
    ],
  },
  logs: {
    level: 'info', // fatal, error, warn, info, verbose, debug, trace
    logsDir: './logs',
    reqLogFormat: 'short', // used for morgan (request logging)
  },
}

git-server uses helix-log for logging. The log level (fatal, error, warn, info, verbose, debug, trace) can be set via the logs.level property in the config (see above). For more information please refer to the helix-log project.

1. Create a local Git repository

cd ./repos
# create org
mkdir helix && cd helix
# initialize new git repo
mkdir test && cd test && git init
# allow to remotely push to this repo
git config receive.denyCurrentBranch updateInstead
# add a README.md
echo '# test repo'>README.md
git add . && git commit -m '1st commit'
cd ../../..

2. Start server

npm start

3. Fetch raw content of file in Git repo over http

curl http://localhost:5000/raw/helix/test/main/README.md

Git Protocols and APIs

1. Git Raw Protocol

Serving content of a file in a git repo.

The requested file is specified by:

  • {owner}: GitHub organization or user
  • {repo}: repository name
  • {ref}: Git reference
    • branch name (e.g. main)
    • tag name (e.g. v1.0)
    • (full or shorthand) commit id (e.g. 7aeff3d)

GitHub URLs:

  • https://raw.githubusercontent.com/{owner}/{repo}/{ref}/path/to/file
  • https://github.com/{owner}/{repo}/raw/{ref}/path/to/file

Local git-server URLs:

  • http://localhost:{port}/raw/{owner}/{repo}/{ref}/path/to/file
  • http://localhost:{port}/{owner}/{repo}/raw/{ref}/path/to/file
  • http://raw.localtest.me:{port}/{owner}/{repo}/{ref}/path/to/file (using wildcarded DNS domain resolving to 127.0.0.1)

Remote examples:

  • https://raw.githubusercontent.com/adobe/git-server/main/README.md
  • https://github.com/adobe/git-server/raw/main/README.md

Local examples:

  • http://raw.localtest.me:5000/adobe/git-server/main/README.md
  • http://localhost:5000/adobe/git-server/raw/main/README.md
  • http://localhost:5000/raw/adobe/git-server/main/README.md

raw.githubusercontent.com serves certain file types (e.g. JavaScript, CSS, HTML) with incorrect Content-Type: text/plain header. 3rd party solutions like rawgit.com address this issue. git-server serves files with correct content type.

2. Git HTTP Transfer Protocols

Support for git clone, push, fetch

Documentation:

git push support

The served local repo needs to be either a bare repo (git clone --bare or git init --bare) or the following option needs to be set:

git config receive.denyCurrentBranch updateInstead

more information

3. GitHub API v3

Documentation: GitHub API v3

GitHub Endpoint: https://api.github.com/

Local endpoint: http://localhost:{port}/api or e.g. http://api.localtest.me:{port} (using wildcarded DNS domain resolving to 127.0.0.1)

Only a small subset of the GitHub API will be supported:

  • Get contents

    Note: The GitHub implementation supports files up to 1 megabyte in size.

  • Get blob

    Note: The GitHub implementation supports blobs up to 100 megabytes in size.

  • Get tree

  • Get commits

  • Get archive link

    Note: This method returns a 302 to a URL to download a tarball or zipball archive for a repository. git-server also supports an unofficial https://codeload.github.com endpoint that is not rate limited and that doesn't redirect:

    • https://codeload.github.com/{owner}/{repo}/[zip|tar.gz]/main

    Related issue/discussion: #5 Support codeload.github.com

Local examples:

  • http://api.localtest.me:5000/repos/adobe/git-server/contents/README.md?ref=main
  • http://api.localtest.me:5000/repos/adobe/project-helix/git/blobs/bf13fe66cbee379db6a3e4ebf0300b8bbc0f01b7
  • http://localhost:5000/api/repos/adobe/git-server/contents/README.md?ref=main
  • http://localhost:5000/api/repos/adobe/project-helix/git/blobs/bf13fe66cbee379db6a3e4ebf0300b8bbc0f01b7

4. GitHub-like Web Server

(not yet implemented)

Endpoint: https://github.com/

e.g.

https://github.com/{owner}/{repo}, https://github.com/{owner}/{repo}/blob/{branch}/path/to/file

Current Tags

  • 0.9.6-nodegit.1                                ...           experimental (2 years ago)
  • 1.3.8                                ...           latest (13 days ago)
  • 0.9.18-pre.37                                ...           next (a year ago)

182 Versions

  • 1.3.8                                ...           13 days ago
  • 1.3.7                                ...           22 days ago
  • 1.3.6                                ...           a month ago
  • 1.3.5                                ...           2 months ago
  • 1.3.4                                ...           2 months ago
  • 1.3.3                                ...           4 months ago
  • 1.3.2                                ...           4 months ago
  • 1.3.1                                ...           4 months ago
  • 1.3.0                                ...           4 months ago
  • 1.2.2                                ...           4 months ago
  • 1.2.1                                ...           5 months ago
  • 1.2.0                                ...           5 months ago
  • 1.1.3                                ...           7 months ago
  • 1.1.2                                ...           8 months ago
  • 1.1.1                                ...           9 months ago
  • 1.1.0                                ...           9 months ago
  • 1.0.16                                ...           9 months ago
  • 1.0.15                                ...           9 months ago
  • 1.0.14                                ...           10 months ago
  • 1.0.13                                ...           10 months ago
  • 1.0.12                                ...           a year ago
  • 1.0.11                                ...           a year ago
  • 1.0.10                                ...           a year ago
  • 1.0.9                                ...           a year ago
  • 1.0.8                                ...           a year ago
  • 1.0.7                                ...           a year ago
  • 1.0.6                                ...           a year ago
  • 1.0.5                                ...           a year ago
  • 1.0.4                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
  • 0.9.18-pre.37                                ...           a year ago
  • 0.9.18-pre.36                                ...           a year ago
  • 0.9.18-pre.35                                ...           a year ago
  • 0.9.18-pre.34                                ...           a year ago
  • 0.9.19                                ...           a year ago
  • 0.9.18-pre.33                                ...           a year ago
  • 0.9.18-pre.32                                ...           a year ago
  • 0.9.18-pre.31                                ...           a year ago
  • 0.9.18-pre.30                                ...           a year ago
  • 0.9.18                                ...           a year ago
  • 0.9.18-pre.29                                ...           a year ago
  • 0.9.18-pre.28                                ...           a year ago
  • 0.9.18-pre.27                                ...           a year ago
  • 0.9.18-pre.26                                ...           a year ago
  • 0.9.18-pre.25                                ...           a year ago
  • 0.9.18-pre.24                                ...           a year ago
  • 0.9.18-pre.23                                ...           a year ago
  • 0.9.18-pre.22                                ...           a year ago
  • 0.9.18-pre.21                                ...           a year ago
  • 0.9.18-pre.20                                ...           a year ago
  • 0.9.18-pre.19                                ...           a year ago
  • 0.9.18-pre.18                                ...           a year ago
  • 0.9.18-pre.17                                ...           a year ago
  • 0.9.18-pre.16                                ...           a year ago
  • 0.9.18-pre.15                                ...           a year ago
  • 0.9.18-pre.14                                ...           a year ago
  • 0.9.18-pre.13                                ...           a year ago
  • 0.9.18-pre.12                                ...           a year ago
  • 0.9.18-pre.11                                ...           a year ago
  • 0.9.18-pre.10                                ...           a year ago
  • 0.9.18-pre.9                                ...           a year ago
  • 0.9.18-pre.8                                ...           a year ago
  • 0.9.18-pre.7                                ...           a year ago
  • 0.9.18-pre.6                                ...           a year ago
  • 0.9.18-pre.5                                ...           a year ago
  • 0.9.18-pre.4                                ...           a year ago
  • 0.9.18-pre.3                                ...           a year ago
  • 0.9.18-pre.2                                ...           a year ago
  • 0.9.18-pre.1                                ...           a year ago
  • 0.9.18-pre.0                                ...           a year ago
  • 0.9.17                                ...           a year ago
  • 0.9.17-pre.10                                ...           a year ago
  • 0.9.17-pre.9                                ...           a year ago
  • 0.9.17-pre.8                                ...           a year ago
  • 0.9.17-pre.7                                ...           a year ago
  • 0.9.17-pre.6                                ...           a year ago
  • 0.9.17-pre.5                                ...           2 years ago
  • 0.9.17-pre.4                                ...           2 years ago
  • 0.9.17-pre.3                                ...           2 years ago
  • 0.9.17-pre.2                                ...           2 years ago
  • 0.9.17-pre.1                                ...           2 years ago
  • 0.9.17-pre.0                                ...           2 years ago
  • 0.9.16                                ...           2 years ago
  • 0.9.16-pre.4                                ...           2 years ago
  • 0.9.16-pre.3                                ...           2 years ago
  • 0.9.16-pre.2                                ...           2 years ago
  • 0.9.16-pre.1                                ...           2 years ago
  • 0.9.16-pre.0                                ...           2 years ago
  • 0.9.15                                ...           2 years ago
  • 0.9.15-pre.3                                ...           2 years ago
  • 0.9.15-pre.2                                ...           2 years ago
  • 0.9.15-pre.1                                ...           2 years ago
  • 0.9.15-pre.0                                ...           2 years ago
  • 0.9.14                                ...           2 years ago
  • 0.9.14-pre.2                                ...           2 years ago
  • 0.9.14-pre.1                                ...           2 years ago
  • 0.9.14-pre.0                                ...           2 years ago
  • 0.9.13                                ...           2 years ago
  • 0.9.13-pre.3                                ...           2 years ago
  • 0.9.13-pre.2                                ...           2 years ago
  • 0.9.13-pre.1                                ...           2 years ago
  • 0.9.13-pre.0                                ...           2 years ago
  • 0.9.12                                ...           2 years ago
  • 0.9.12-pre.3                                ...           2 years ago
  • 0.9.12-pre.2                                ...           2 years ago
  • 0.9.12-pre.1                                ...           2 years ago
  • 0.9.12-pre.0                                ...           2 years ago
  • 0.9.11                                ...           2 years ago
  • 0.9.11-pre.7                                ...           2 years ago
  • 0.9.11-pre.6                                ...           2 years ago
  • 0.9.11-pre.5                                ...           2 years ago
  • 0.9.11-pre.4                                ...           2 years ago
  • 0.9.11-pre.3                                ...           2 years ago
  • 0.9.11-pre.2                                ...           2 years ago
  • 0.9.11-pre.1                                ...           2 years ago
  • 0.9.11-pre.0                                ...           2 years ago
  • 0.9.10                                ...           2 years ago
  • 0.9.10-pre.5                                ...           2 years ago
  • 0.9.10-pre.4                                ...           2 years ago
  • 0.9.10-pre.3                                ...           2 years ago
  • 0.9.10-pre.2                                ...           2 years ago
  • 0.9.10-pre.1                                ...           2 years ago
  • 0.9.10-pre.0                                ...           2 years ago
  • 0.9.9                                ...           2 years ago
  • 0.9.9-pre.0                                ...           2 years ago
  • 0.9.8                                ...           2 years ago
  • 0.9.8-pre.1                                ...           2 years ago
  • 0.9.7                                ...           2 years ago
  • 0.9.8-pre.0                                ...           2 years ago
  • 0.9.6                                ...           2 years ago
  • 0.9.6-nodegit.1                                ...           2 years ago
  • 0.9.6-pre.1                                ...           2 years ago
  • 0.9.6-pre.0                                ...           2 years ago
  • 0.9.5                                ...           2 years ago
  • 0.9.4                                ...           2 years ago
  • 0.9.4-pre.0                                ...           2 years ago
  • 0.9.3                                ...           2 years ago
  • 0.9.2-pre.5                                ...           2 years ago
  • 0.9.2-pre.4                                ...           2 years ago
  • 0.9.2-pre.3                                ...           2 years ago
  • 0.9.2-pre.2                                ...           2 years ago
  • 0.9.2-pre.1                                ...           2 years ago
  • 0.9.2-pre.0                                ...           2 years ago
  • 0.9.1-SNAPSHOT.95                                ...           2 years ago
  • 0.9.1-SNAPSHOT.92                                ...           2 years ago
  • 0.9.1-SNAPSHOT.90                                ...           2 years ago
  • 0.9.1-SNAPSHOT.85                                ...           2 years ago
  • 0.9.1-SNAPSHOT.83                                ...           2 years ago
  • 0.9.0-SNAPSHOT.81                                ...           2 years ago
  • 0.9.0                                ...           2 years ago
  • 0.0.3-SNAPSHOT.79                                ...           2 years ago
  • 0.0.3-SNAPSHOT.77                                ...           2 years ago
  • 0.0.3-SNAPSHOT.75                                ...           2 years ago
  • 0.0.3-SNAPSHOT.73                                ...           2 years ago
  • 0.0.3-SNAPSHOT.70                                ...           2 years ago
  • 0.0.2-SNAPSHOT.68                                ...           2 years ago
  • 0.0.2-SNAPSHOT.66                                ...           2 years ago
  • 0.0.2-SNAPSHOT.64                                ...           2 years ago
  • 0.0.2-SNAPSHOT.60                                ...           2 years ago
  • 0.0.2-SNAPSHOT.58                                ...           2 years ago
  • 0.0.2-SNAPSHOT.56                                ...           2 years ago
  • 0.0.2-SNAPSHOT.54                                ...           2 years ago
  • 0.0.2-SNAPSHOT.52                                ...           2 years ago
  • 0.0.2-SNAPSHOT.46                                ...           2 years ago
  • 0.0.2-SNAPSHOT.44                                ...           2 years ago
  • 0.0.2-SNAPSHOT.39                                ...           2 years ago
  • 0.0.2-SNAPSHOT.37                                ...           2 years ago
  • 0.0.2-SNAPSHOT.35                                ...           2 years ago
  • 0.0.2-SNAPSHOT.33                                ...           2 years ago
  • 0.0.2-SNAPSHOT.24                                ...           2 years ago
  • 0.0.2-SNAPSHOT.22                                ...           2 years ago
  • 0.0.2                                ...           2 years ago
  • 0.0.1-SNAPSHOT.20                                ...           2 years ago
  • 0.0.1-SNAPSHOT.16                                ...           2 years ago
  • 0.0.1-SNAPSHOT.13                                ...           2 years ago
  • 0.0.1-SNAPSHOT.10                                ...           2 years ago
  • 0.0.1-SNAPSHOT.8                                ...           2 years ago
  • 0.0.1-SNAPSHOT.6                                ...           2 years ago
  • 0.0.1-SNAPSHOT.4                                ...           2 years ago

Copyright 2014 - 2016 © taobao.org |