Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[lib] changed location of repo methods

  • Loading branch information...
commit cbe50ff7db68423f1040479477c78cc5d407a0b8 1 parent b4a0262
@hij1nx authored
Showing with 61 additions and 25 deletions.
  1. +17 −24 README.md
  2. +2 −1  lib/repo.js
  3. +42 −0 test/tests/push.js
View
41 README.md
@@ -8,39 +8,29 @@ var gitstream = require('git-stream')
// this does not include all of the files, only
// the git components such as trees and blobs.
//
-var r = gitstream.createRepo()
+var repo = gitstream.createRepo({ path: './fixtures/a/a' })
-//
-// add a remote (an in memory operation) currently
-// only supports the tcp transport protocol.
-//
-r.remote.add({
+repo.remote.add({
name: 'origin',
branch: 'master',
host: '127.0.0.1',
port: '8000',
- path: '/foo/bar'
+ path: '/fixtures/a/b'
})
//
-// or read the config from the repo and get a
-// remote from there.
+// add some stuff, commit and push it to the remote
//
-r.config.getAll({ path: './git' }, function(config) {
+var file = fs.createReadStream('./README.md')
+var reader = fstream.Reader({ path: repo.path })
- var origin = config.remote.origin;
+repo.pull('origin')
- //
- // add a file, commit it and push it to the remote
- //
- var file = fs.createReadStream('./README.md')
+ .pipe(repo.add(file))
+ .pipe(repo.add(reader))
- r.pull('origin')
- .pipe(r.add(file))
- .pipe(r.commit({ m: 'first commit!' }))
- .pipe(r.push('origin'))
-
-})
+ .pipe(repo.commit ({ m: 'first commit!' }))
+ .pipe(repo.push('origin'))
```
@@ -59,10 +49,13 @@ net.createServer(function(socket) {
//
// when the socket connects and gets data
//
+ var repo = git.createRepo({ path: '/fixtures/b' })
+ var writer = fstream.Writer({ path: repo.path })
+
socket
- .pipe(gitstream.Repo())
- .pipe(gitstream.checkout('master'))
- .on('file', onfile)
+ .pipe(repo)
+ .pipe(repo.checkout('master'))
+ .pipe(writer)
}).listen(8000)
View
3  lib/repo.js
@@ -159,6 +159,8 @@ var Repo = module.exports = function Repo(opts) {
util.inherits(Repo, Stream);
Git.prototype.push = require('./lib/push');
+Git.prototype.checkout = require('./lib/checkout');
+
// Git.prototype.add = require('./lib/add');
// Git.prototype.commit = require('./lib/commit');
@@ -175,7 +177,6 @@ Repo.prototype.end = function(data) {
};
-
Repo.prototype.config = {
getAll: function(opts, callback) {
View
42 test/tests/push.js
@@ -0,0 +1,42 @@
+
+var test = require('tap').test
+var Gitstream = require('../../git-stream')
+
+var git = new Gitstream()
+
+module.exports = {
+
+ "A repo should receive a push from another repo": function(test) {
+
+ test.plan(1)
+
+ //
+ // get a repository from the fixtures directory and
+ // send it to the origin (on the same machine).
+ //
+ var repo = git.createRepo({ path: './fixtures/repos/a' })
+
+ repo.remote.add({
+ name: 'origin',
+ branch: 'master',
+ host: '127.0.0.1',
+ port: '8000',
+ path: '/fixtures/a/b'
+ })
+
+ repo.push('origin')
+
+ net.createServer(function(socket) {
+
+ var repo = git.createRepo({ path: '/fixtures/a/b' })
+ var writer = fstream.Writer({ path: repo.path })
+
+ socket
+ .pipe(repo)
+ .pipe(repo.checkout('master'))
+ .pipe(writer)
+
+ }).listen(8000)
+
+ })
+}

0 comments on commit cbe50ff

Please sign in to comment.
Something went wrong with that request. Please try again.