在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:stackdot/NodeJS-Git-Server开源软件地址:https://github.com/stackdot/NodeJS-Git-Server开源编程语言:JavaScript 98.7%开源软件介绍:NodeJS Git ServerA multi-tenant git server using NodeJS. Read the Documented Source Code Here Made to be able to support many git repo's and users with Read/Write customizable permissions. Install Git ServerTo install the git server run:
To run tests
Example UsageThe GitServer is a very easy to get up and running git server. It uses the Pushover and git-emit modules for listening to git events, and its own layer to do the security for each repo & user. var GitServer = require('git-server');
var newUser = {
username:'demo',
password:'demo'
}
var newRepo = {
name:'myrepo',
anonRead:false,
users: [
{ user:newUser, permissions:['R','W'] }
]
}
server = new GitServer({repos: [ newRepo ]}); Events:Server object emits these events: ##passive events These events are informational only. They can not be aborted.
##abortable events These events can be aborted or accepted. If there will be no listeners for any of these events, they will be automatically accepted. If object can be aborted, it will have canAbort property in update argument.
var GitServer = require('git-server');
var newUser = {
username:'demo',
password:'demo'
}
var newRepo = {
name:'myrepo',
anonRead:false,
users: [
{ user:newUser, permissions:['R','W'] }
]
}
server = new GitServer({repos: [ newRepo ]});
server.on('commit', function(update, repo) {
// do some logging or other stuff
update.accept() //accept the update.
});
server.on('post-update', function(update, repo) {
//do some deploy stuff
}); When we start the git server, it will default to port 7000. We can test this using git on this (or another ) machine.
Since this repo does NOT allow anonymous reading, it will prompt us for a user/pass To make this faster, we can use the basic auth structure:
This should not prompt you for any user/pass. Also in the future when you push changes, or pull, it will not ask you for this info again. Repo objectRepo object is the object passed to start the server plus some additional methods and properties. {
name: 'stackdot',
anonRead: false,
users: [ { user: {username: "demo", password: "demo"}, permissions: ["R", "W"] } ],
path: '/tmp/repos/stackdot.git',
last_commit: {
status: 'pending',
repo: 'anon.git',
service: 'receive-pack',
cwd: '/tmp/repos/stackdot.git',
last: '00960000000000000000000000000000000000000000',
commit: '67359bb4a6cddd97b59507413542e0b08ef078b0',
evName: 'push',
branch: 'master'
}
} Update object
{
cwd: '/tmp/repos/stackdot.git', // Current repo dir
repo: 'stackdot.git', // Repo name
accept: [Function], // Method to accept request (if aplicable)
reject: [Function], // Method to reject request (if aplicable)
exists: true, // Does the repo exist
name: 'fetch', // Event name
canAbort: true // If event can be abbortable
} HTTPSThe ability to use HTTPS is now implemented for the module and the cli. This is important so that your username & password is encrypted when being sent over the wire. If you are not using username/password then you may want to disregard this section. To enable HTTPS in the module, use the 'cert' param: var fs = require('fs');
var certs = {
key : fs.readFileSync('../certs/privatekey.pem')
cert : fs.readFileSync('../certs/certificate.pem')
};
_g = new GitServer({repos: [ newRepo ]}, undefined, undefined, undefined, certs); To enable HTTPS in the cli, use the '--ssl' option along with '--key' and '--cert' options:
To create these certs you can run:
Also, be aware that when using HTTPS for the git server, when you try to clone,etc. It will give you an SSL error because git (which uses CURL) cannot verify the SSL Cert. To correct this, install a actual, verified SSL Cert ( Free ones here: StartCom ) If you want to keep using the self signed cert like we created above ^ just tell git to not verify the cert. ( Other ways to do it here )
And you are good to go! CLI UsageWhen you install this package globally using
You will now have a CLI interface you can run and interact with. Get started by typing You should see something similar to this: With this interface you can type the following to see the available commands:
You will see a list of possible commands, just enter a command and the prompt will ask you for any additional details needed. TODO Items
This is a work in progress - please feel free to contribute!please contribute #License (The MIT License) Copyright (c) 2016 Quinton Pike Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论