Skip to content

Allow any ref, not just tags or branches #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 27 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
97d2737
updates docs (#26)
gabrielcsapo Nov 10, 2017
faad289
updates duplex lib to fix cork,uncork and change the behavior of writ…
echopoint Nov 10, 2017
d9aabdf
0.3.4
gabrielcsapo Nov 10, 2017
6d80414
updates docs page
gabrielcsapo Nov 24, 2017
0961dac
makes authenticate more flexible (#30)
gabrielcsapo Dec 4, 2017
abd8fa4
0.4.0
gabrielcsapo Dec 4, 2017
f3f7396
fixes type to be the same as the event names (#32)
gabrielcsapo Dec 5, 2017
9aec84c
adds https support (#35)
gabrielcsapo Dec 8, 2017
2d9d4c8
0.4.2
gabrielcsapo Dec 8, 2017
415e23d
updates tryitout and docs
gabrielcsapo Jan 13, 2018
8202863
Fix for #38 (#39)
hasezoey May 29, 2018
21dc88e
0.4.3
gabrielcsapo May 31, 2018
f19a1c1
Change to support node-git-server on windows as per (#41)
insidelogic Nov 27, 2018
dd20baf
0.5.0
gabrielcsapo Nov 27, 2018
4c974e3
Merge branch 'master' of github.com:gabrielcsapo/node-git-server
gabrielcsapo Nov 27, 2018
d7840c3
add return value to listen method (#44)
mojavelinux Dec 4, 2018
442e48d
remove useless 'new' calls (#48)
ravener Dec 7, 2018
62b1cb6
return promise from close method if callback method not specified (#46)
mojavelinux Dec 8, 2018
70ad208
0.5.1
gabrielcsapo Mar 3, 2019
e0bfae6
[feature] adds the ability to introspect on the header for the authen…
gabrielcsapo Mar 6, 2019
e3ae373
Fix an example (#55)
pitust Apr 28, 2019
ac26650
Security Issue (#62)
masasron Mar 29, 2020
931a1c6
0.6.1
gabrielcsapo Mar 29, 2020
5279f64
[testing] test against lts node versions
gabrielcsapo Mar 30, 2020
3f7407d
tag.version is the tag not the repo (#72)
chmac Sep 14, 2020
a7682b7
Swap upload / download to fetch / push. (#73)
chmac Sep 14, 2020
54adccd
Hack in a change to allow pushing refs that are not tags or branches
mattwynne Mar 15, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ coverage
example/test
example/tmp
package-lock.json
.vs/
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ script:
- npm run coverage
- cat coverage/lcov.info | lcov-server --upload https://lcov-server.gabrielcsapo.com
node_js:
- "6"
- "8"
- "10"
- "12"
os:
- linux
sudo: false
11 changes: 9 additions & 2 deletions tryitout.js → .tryitout
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
body: `
<div style="width:80%;position: absolute;left: 50%;top: 50%;-webkit-transform: translate(-50%, -50%);transform: translate(-50%, -50%);">
<h3 class="text-center" style="font-weight: 100"> ${description} </h3>
<pre style="background-color:rgb(7, 7, 7);color:rgb(228, 228, 228);white-space: pre;text-align:left;width: auto;display:inline-block;">
<pre id="code" style="white-space: pre;text-align:left;width: auto;display:inline-block;">
const Server = require('node-git-server');
const repo = new Server(path.resolve(__dirname, 'tmp'), {
autoCreate: true,
Expand All @@ -31,5 +31,12 @@ module.exports = {
},
footer: `
<div class="text-black">Made with ☕️ by <a href="http://www.gabrielcsapo.com">@gabrielcsapo</a></div>
`
`,
template: 'landing',
output: './docs',
externals: [
"./docs/krayon.css",
"./docs/krayon.min.js",
"./docs/main.js"
]
};
42 changes: 42 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
# 0.6.1 (03/03/2019)

- Fixes bug with being able to overwrite git repos that a user doesn't have access to. @masasron

# 0.6.0 (03/03/2019)

- Augments the authenticate function declaration to accept an object as the first argument and a callback for the second. This allows us to make changes without having to cause breaking changes.
- Adds the ability to introspect on the header (fixes #49)

# 0.5.1 (03/03/2019)

- bump dependencies
- tap `^11.0.1` -> `^12.5.3`
- tryitout `^2.0.6` -> `^2.1.1`

# 0.5.0 (11/27/2018)

- adds `log` functionality for event streams and response streams

# 0.4.3 (04/30/2018)

- removes deprecated `Buffer` interface

# 0.4.2 (12/07/2017)

- adds https support

# 0.4.1 (12/04/2017)

- fixes type to be the same as the event names

# 0.4.0 (12/03/2017)

- [BREAKING] changes the interface for authentication to make it more flexible
- when error is sent back to client ensure error is string

# 0.3.4 (11/10/2017)

- updates duplex lib to fix cork, uncork and add some chaining
- adds extensive docs to Git, Util and Service
- adds named function to events to trace errors more easily

# 0.3.3 (11/05/2017)

- Removes dependency on http-duplex package replacing w/ internal replacement lib
Expand Down
143 changes: 135 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

> 🎡 A configurable git server written in Node.js

>> there be 🐲 here! The API's and functionality are still be cemented, anything before a 1.0.0 release will be subject to change.

[![Npm Version](https://img.shields.io/npm/v/node-git-server.svg)](https://www.npmjs.com/package/node-git-server)
[![Build Status](https://travis-ci.org/gabrielcsapo/node-git-server.svg?branch=master)](https://travis-ci.org/gabrielcsapo/node-git-server)
[![Coverage Status](https://lcov-server.gabrielcsapo.com/badge/github%2Ecom/gabrielcsapo/node-git-server.svg)](https://lcov-server.gabrielcsapo.com/coverage/github%2Ecom/gabrielcsapo/node-git-server)
Expand All @@ -18,26 +20,135 @@ npm install node-git-server

# Usage

## Simple

```javascript
const path = require('path');
const Server = require('node-git-server');

const repos = new Server(path.resolve(__dirname, 'tmp'), {
autoCreate: true
});
const port = process.env.PORT || 7005;

repos.on('push', (push) => {
console.log(`push ${push.repo}/${push.commit} (${push.branch})`);
push.accept();
});

repos.on('fetch', (fetch) => {
console.log(`fetch ${fetch.commit}`);
fetch.accept();
});

repos.listen(port, () => {
console.log(`node-git-server running at http://localhost:${port}`)
});
```

then start up the node-git-server server...

```
$ node example/index.js
```

meanwhile...

```
$ git push http://localhost:7005/beep master
Counting objects: 356, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (133/133), done.
Writing objects: 100% (356/356), 46.20 KiB, done.
Total 356 (delta 210), reused 355 (delta 210)
To http://localhost:7005/beep
* [new branch] master -> master
```

## Sending logs

```javascript
const path = require('path');
const Server = require('node-git-server');

const repos = new Server(path.resolve(__dirname, 'tmp'), {
autoCreate: true
});
const port = process.env.PORT || 7005;

repos.on('push', (push) => {
console.log(`push ${push.repo}/${push.commit} (${push.branch})`);

repos.list((err, results) => {
push.log(' ');
push.log('Hey!');
push.log('Checkout these other repos:');
for(const repo of results) {
push.log(`- ${repo}`);
}
push.log(' ');
});

push.accept();
});

repos.listen(port, () => {
console.log(`node-git-server running at http://localhost:${port}`)
});
```

then start up the node-git-server server...

```
$ node example/index.js
```

meanwhile...

```
$ git push http://localhost:7005/beep master
Counting objects: 356, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (133/133), done.
Writing objects: 100% (356/356), 46.20 KiB, done.
Total 356 (delta 210), reused 355 (delta 210)
remote:
remote: Hey!
remote: Checkout these other repos:
remote: - test.git
remote:
To http://localhost:7005/test
77bb26e..22918d5 master -> master
```

### Authentication

```javascript
const path = require('path');
const Server = require('node-git-server');
const repo = new Server(path.resolve(__dirname, 'tmp'), {

const repos = new Server(path.resolve(__dirname, 'tmp'), {
autoCreate: true,
authenticate: (type, repo, username, password, next) => {
console.log(type, repo, username, password);
next();
authenticate: ({type, repo, user}, next) => {
if(type == 'push') {
user((username, password) => {
console.log(username, password);
next();
});
} else {
next();
}
}
});
const port = process.env.PORT || 7005;

repos.on('push', (push) => {
console.log('push ' + push.repo + '/' + push.commit
+ ' (' + push.branch + ')'
);
console.log(`push ${push.repo}/${push.commit} (${push.branch})`);
push.accept();
});

repos.on('fetch', (fetch) => {
console.log('fetch ' + fetch.commit);
console.log(`fetch ${fetch.commit}`);
fetch.accept();
});

Expand Down Expand Up @@ -65,6 +176,22 @@ To http://localhost:7005/beep
* [new branch] master -> master
```

# Example

Running the following command will start up a simple http server:

```
node example/index.js
```

If you want to try using https run the following

```
node example/index.js --https
```

> When running https with self-signed certs there are two ways to override the git-clients behavior using `git config http.sslVerify false` or `git config --global http.sslCAInfo /path/to/cert.pem`

For more information please visit the [docs](http://www.gabrielcsapo.com/node-git-server/code/index.html)

# Philosophy
Expand Down
Loading