Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug 458883 - node.js implementation of git pages using nodegit
Squashed commit of the following:

commit 8576a27
Author: Lef Ioannidis <elefthei@mit.edu>
Date:   Fri May 8 02:17:00 2015 -0400

    Fixed minor bug in Git stash, it now works.

    Signed-off-by: Lef Ioannidis <elefthei@mit.edu>

commit 415efac
Author: Lef Ioannidis <elefthei@mit.edu>
Date:   Fri May 8 02:01:21 2015 -0400

    Finished git stash listing functionality. Moved to NodeGit 0.4.0 which
    implements Stash.foreach(repo, callback), needed for git stash listing.

    Signed-off-by: Lef Ioannidis <elefthei@mit.edu>

commit e4123b2
Author: Lef Ioannidis <elefthei@mit.edu>
Date:   Fri May 8 01:57:57 2015 -0400

    Revert "Patched status for promise"

    This reverts commit ca8dba3c5a3222fa0cc77239bb411a99a5339c81.

    Signed-off-by: Lef Ioannidis <elefthei@mit.edu>

commit d350047
Author: Lef Ioannidis <elefthei@mit.edu>
Date:   Fri May 8 01:01:32 2015 -0400

    Removed hardcoded path definitions from lib/git/stash.js

    Signed-off-by: Lef Ioannidis <elefthei@mit.edu>

commit 545fb7d
Author: brandonadalesandro <brandonadalesandro@gmail.com>
Date:   Wed May 6 12:14:42 2015 -0700

    Patched status for promise

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit 336656a
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Wed May 6 01:03:56 2015 -0400

    Added test for getting list of remotes.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 0213962
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Wed May 6 00:03:11 2015 -0400

    Added third test case with branches. Fixed resp code for branch.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit bf58208
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Tue May 5 23:53:04 2015 -0400

    Add test for push.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit d4b0290
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Tue May 5 23:26:12 2015 -0400

    Added tests for cloning a repo and listing tags.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit e1cc656
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Tue May 5 22:51:41 2015 -0400

    Add clone, but not using task to do it.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 1ae977b
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Tue May 5 22:52:34 2015 -0400

    Added test nodegit checks for deleting remotes and repo.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 2a882f5
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Tue May 5 22:21:25 2015 -0400

    Add push. Seems to be working. Added force push.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 16231e3
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Tue May 5 18:17:33 2015 -0400

    Add tasks, pushing almost working.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 5770cb7
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Tue May 5 14:39:44 2015 -0400

    Try mocking a fake result for the task from pushing when there are no credentials.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 07ac1f3
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Tue May 5 03:04:00 2015 -0400

    Add code for pushing. Need to figure out how to ask for authentication.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 592476c
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Tue May 5 02:35:56 2015 -0400

    Deleted unneeded test file, fixed commit/diff change, added fetching from remote test.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 9ecee34
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Tue May 5 01:40:52 2015 -0400

    Fix remote branch names not being returned correctly.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit e7b163b
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Tue May 5 01:29:00 2015 -0400

    Check if adding remote URL has a protocol, add fetch, remove unused dependencies,
    make login return an anonymous user.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit a153205
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Mon May 4 18:38:44 2015 -0400

    Add console.logs, mock a login response.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit d1df3cc
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Mon May 4 17:53:16 2015 -0400

    Fixed and refactored commit object code.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 757623b
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Sat May 2 02:44:59 2015 -0400

    Fix switching between remotes.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit fbfebd9
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Sat May 2 01:30:26 2015 -0400

    Added skeleton code for fetching and pushing to a remote.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 142312c
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Sat May 2 00:52:32 2015 -0400

    Add test for adding remote.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit a6ebf34
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Sat May 2 00:43:07 2015 -0400

    Add test for deleting a repository route.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 672fbfd
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Sat May 2 00:24:40 2015 -0400

    Added tests for init repo, adding file, committing a file.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit bfb279e
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Fri May 1 18:53:28 2015 -0400

    Added removing repo after "init repo" test in test-git-api.js.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 032dc9d
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Fri May 1 18:43:48 2015 -0400

    Add first test for creating a repo.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 820b0d0
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Fri May 1 17:20:36 2015 -0400

    Revert "trying to debug what's wrong with status, I did clean up some missing semi-colons."

    This reverts commit 04d15cf7b3ee464a6a5263f6159f7be407f6d65e.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 351adec
Author: Brandona Dalesandro <brandonadalesandro@gmail.com>
Date:   Thu Apr 30 11:02:14 2015 -0700

    trying to debug what's wrong with status, I did clean up some missing semi-colons.

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit 22adf7c
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Mon Apr 27 23:42:36 2015 -0400

    Fixed pagination for commitLog, added previous and next locations.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit a2e7830
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Mon Apr 27 22:46:20 2015 -0400

    Fixed getCommitLog for reference, fixed diff for untracked files, fixed
    "/" for status folders, fixed not returning commit log if no full page
    of commits.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit f07b870
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Mon Apr 27 21:58:09 2015 -0400

    Fixed diff for untracked files, putting catch error in index (add.js)
    for when file not found in index.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 0b93a6f
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Mon Apr 27 21:36:56 2015 -0400

    Correctly read file from index (in add.js), which also fixed diff.js.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 82856f0
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Mon Apr 27 19:35:57 2015 -0400

    Fixed status and adding files.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 9e7b5cc
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Mon Apr 27 18:32:53 2015 -0400

    Finish get commit revisions.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit ea14f94
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Mon Apr 27 17:59:52 2015 -0400

    Try doing rev list.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit b8b38b5
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Mon Apr 27 16:44:10 2015 -0400

    Change logic for commit routes.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit badb7cc
Author: Lef Ioannidis <elefthei@mit.edu>
Date:   Mon Apr 27 03:17:21 2015 -0400

    Link together git_stash_foreach and Orion git stash. Need to convert NodeGit repo to a JSON response for this to work.

    Signed-off-by: Lef Ioannidis <elefthei@mit.edu>

commit f30cde9
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Mon Apr 27 01:29:53 2015 -0400

    Fix committing all files in index.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 10f1f30
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Mon Apr 27 01:06:01 2015 -0400

    Remove unused code from commit, add initial commit to init.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 68b6098
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Mon Apr 27 00:39:53 2015 -0400

    Fix git commit log route. Not working on front end.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 60ba07a
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Sun Apr 26 23:34:35 2015 -0400

    Add debugging logs.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 6aa10a7
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Sun Apr 26 22:05:40 2015 -0400

    Make some fixes for committing.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit c411662
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Sun Apr 26 21:36:56 2015 -0400

    Try fixing commit.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 7b5dab2
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Sun Apr 26 21:59:30 2015 -0400

    Fixed some bugs in add.js ("/" issues in routes.)

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 067c48a
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Sun Apr 26 21:14:24 2015 -0400

    Working postStage (unstaging files) in add.js.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 1b041b7
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Sun Apr 26 20:18:29 2015 -0400

    Fix adding multiple files.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit e773038
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Fri Apr 24 19:19:36 2015 -0400

    Fix staging one file. Diff on a new file added to index is not working.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 4248d7b
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Fri Apr 24 18:18:56 2015 -0400

    Try fixing diff for new, untracked files. (Mostly unsuccesfully.)

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit a53e8e1
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Fri Apr 24 17:23:27 2015 -0400

    Change how clone is called.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit aa06945
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Fri Apr 24 16:58:20 2015 -0400

    Fixed bug in getClone.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 140b050
Author: Lef Ioannidis <elefthei@mit.edu>
Date:   Fri Apr 24 16:33:23 2015 -0400

    Remember to update stash.js, added nodegit compatibility comments.

    Signed-off-by: Lef Ioannidis <elefthei@mit.edu>

commit 1d3d560
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Fri Apr 24 16:00:23 2015 -0400

    Working getRemotesBranches in remotes.js.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit df616ab
Author: brandonawylie <brandonadalesandro@gmail.com>
Date:   Wed Apr 22 08:57:43 2015 -0700

    fixed request parsing in add.js

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit e1d9ef8
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Mon Apr 20 19:22:46 2015 -0400

    Started getRemotesBranches in remotes.js.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 1f427b3
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Mon Apr 20 18:39:06 2015 -0400

    Add adding remote.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 48cd942
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Mon Apr 20 18:23:46 2015 -0400

    Actually fix get remotes.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 6f1566d
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Mon Apr 20 18:13:51 2015 -0400

    Fix remotes not working due to nodegit API change.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit db7da7f
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Mon Apr 20 17:46:38 2015 -0400

    Added deleteRemote in remotes.js.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 5fc3951
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Mon Apr 20 17:22:32 2015 -0400

    Finished POST getDiffLocation in diff.js.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit a99b7db
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Mon Apr 20 17:04:50 2015 -0400

    Finished diffBetweenTwoCommits in diff.js.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 2cd6f4c
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Mon Apr 20 16:32:27 2015 -0400

    Skeleton code for diff between 2 commits.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit de6890f
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Mon Apr 20 16:27:54 2015 -0400

    Working getDiffBetweenIndexAndHead function in diff.js.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit cc2fa50
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Mon Apr 20 15:57:47 2015 -0400

    Fix refactored diff code.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit cb24370
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Mon Apr 20 15:31:36 2015 -0400

    Add skeleton code for new diff routes

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit a614005
Author: Brandon Dalesandro <brandonadalesandro@gmail.com>
Date:   Mon Apr 13 16:31:29 2015 -0700

    fixed postcommit to use given arg Email/User instead of grabbing from config

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit 16740f2
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Fri Apr 10 21:19:14 2015 -0400

    Refactored code for diff.js.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit d1f4796
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Fri Apr 10 21:01:45 2015 -0400

    Working gitapi/diff.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 0ad6a97
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Fri Apr 10 20:28:45 2015 -0400

    Sending response, but looks like we need to change how we process the route (sending the diff for a specific file instead).

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 424a9c0
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Fri Apr 10 19:50:48 2015 -0400

    Kind of getting diff working.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 2c75427
Author: Brandon Dalesandro <brandonadalesandro@gmail.com>
Date:   Wed Apr 8 09:01:18 2015 -0700

    fixed bug in commit

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit 2edc8f8
Author: Brandon Dalesandro <brandonadalesandro@gmail.com>
Date:   Wed Apr 8 08:57:55 2015 -0700

    added config get to postcommit

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit 40248b0
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Tue Apr 7 00:45:45 2015 -0400

    Added skeleton code for diff.js.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit aa5a9ac
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Tue Apr 7 00:09:51 2015 -0400

    Removed console.log statements from clone.js, added getFileContent to
    commit.js.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 212c0d7
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Mon Apr 6 23:17:10 2015 -0400

    Removed unused dependencies in commit.js

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 8d03dd6
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Mon Apr 6 23:13:44 2015 -0400

    Fix clone looking for nested repos.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 9d72915
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Mon Apr 6 21:31:50 2015 -0400

    Fixed status--> file error in status.js.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 271e9db
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Mon Apr 6 21:20:51 2015 -0400

    Added code for status.js (now works).

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit ea15312
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Mon Apr 6 20:54:37 2015 -0400

    Updated package.json pty.js so that it can build on OSX. Change nodegit
    dependency to 0.3.3.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 37a6bc1
Author: Brandon Dalesandro <brandonadalesandro@gmail.com>
Date:   Thu Apr 2 18:17:05 2015 -0700

    added some commit changes

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit 7a95c1a
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Sun Mar 29 17:19:52 2015 -0400

    Added getCommitMetadata to commit.js.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit e1dabfd
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Sat Mar 28 21:37:40 2015 -0400

    Added GET commit log to commit.js.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit ddaa94a
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Sat Mar 28 20:43:33 2015 -0400

    Added GET, POST, and DELETE for branch.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit c125993
Author: Brandon Dalesandro <brandonadalesandro@gmail.com>
Date:   Fri Mar 27 23:39:08 2015 -0700

    starting git commit

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit 744fa53
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Fri Mar 27 20:22:32 2015 -0400

    Removed console.log statements.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 93295bd
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Fri Mar 27 20:06:58 2015 -0400

    Use nodegit instead of reading files directly for get branches.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 295798a
Author: Brandon Dalesandro <brandonadalesandro@gmail.com>
Date:   Thu Mar 26 02:38:41 2015 -0700

    work on git blame

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit 585ccb5
Author: Brandon Dalesandro <brandonadalesandro@gmail.com>
Date:   Sat Mar 21 23:08:28 2015 -0700

    started on git blame

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit 7bd6ac8
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Sat Mar 21 18:00:44 2015 -0400

    Added DELETE method for tags.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 0abeb18
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Sat Mar 21 16:52:53 2015 -0400

    Added POST for config (changed git.js for path and added postConfig in
    config.js).

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit aa3e937
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Sat Mar 21 16:29:38 2015 -0400

    Removed (unused) path library, used config.setString from nodegit in
    putConfig(*).

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 18a21e3
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Sat Mar 21 15:43:27 2015 -0400

    Got rid of (unused) path library in branches.js.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 4af577a
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Sat Mar 21 15:34:29 2015 -0400

    Remove mkdirp which wasn't being used. Use isTag() and lookup for checking tags.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 15d0687
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Sat Mar 21 14:00:39 2015 -0400

    Removed findit from code that doesn't use it.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit ce81577
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Sat Mar 21 13:30:16 2015 -0400

    Fixed path for nodegit.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 331ba14
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Fri Mar 6 14:43:58 2015 -0500

    Fix using master for node-git instead of release

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 664b5be
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Sat Feb 28 23:01:01 2015 -0500

    Try adding put config

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 0728dbc
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Sat Feb 28 22:15:14 2015 -0500

    Fixed branch issue, added conditions for checking inside two files.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit e398d64
Author: Brandon Dalesandro <brandonadalesandro@gmail.com>
Date:   Thu Feb 26 15:45:04 2015 -0800

    added reading index, currently commented out

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit cd3d574
Author: Lef Ioannidis <elefthei@mit.edu>
Date:   Thu Feb 26 01:15:23 2015 -0500

    Begun implementation of /gitapi/stash. Note: This isn't in the Specs but works on the Java server.

    Signed-off-by: Lef Ioannidis <elefthei@mit.edu>

commit 7b15b1e
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Sat Feb 21 03:03:47 2015 -0500

    Almost finished listing git branches. Hardcoded a few values, missing
    some methods but they show up on the page.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 7e3fa36
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Sat Feb 21 02:18:30 2015 -0500

    Add git config for a single key

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 4931809
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Fri Feb 20 22:04:05 2015 -0500

    Add get Configs

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 1b7729c
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Fri Feb 20 17:38:37 2015 -0500

    Add ini dependency to parse git config file

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 1906415
Author: Brandon Dalesandro <brandonadalesandro@gmail.com>
Date:   Thu Feb 19 23:34:22 2015 -0800

    Can now unstage files

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit 477b0ad
Author: Brandon Dalesandro <brandonadalesandro@gmail.com>
Date:   Thu Feb 19 12:13:46 2015 -0800

    You can now stage files

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit 3b78252
Author: Brandon Dalesandro <brandonadalesandro@gmail.com>
Date:   Tue Feb 17 23:54:36 2015 -0800

    Added staging of one or multiple files to add.js

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit 5a2c530
Author: Lef Ioannidis <elefthei@mit.edu>
Date:   Tue Feb 17 18:55:36 2015 -0500

    Moved the git init code in git/clone.js: postInit()
    Probably need to change POST responce to reference remote location.

    Signed-off-by: Lef Ioannidis <elefthei@mit.edu>

commit d11a429
Author: Brandon Dalesandro <brandonadalesandro@gmail.com>
Date:   Tue Feb 17 12:12:22 2015 -0800

    Moved init 409 error from git.js to clone.js

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit 27d8f71
Author: Brandon Dalesandro <brandonadalesandro@gmail.com>
Date:   Tue Feb 17 12:08:49 2015 -0800

    Removed dup init/clone code (what the heck?) and cleaned up calls in git.js

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit fb80473
Author: Lef Ioannidis <elefthei@mit.edu>
Date:   Mon Feb 16 21:12:07 2015 -0500

    Finished git init implementation. Sends HTTP 409 response when repository exists already.

    Signed-off-by: Lef Ioannidis <elefthei@mit.edu>

commit d8cda5a
Author: Lef Ioannidis <elefthei@mit.edu>
Date:   Wed Feb 4 10:40:21 2015 -0500

    Started implementation of git init

    Signed-off-by: Lef Ioannidis <elefthei@mit.edu>

commit 8ed849a
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Sat Feb 14 18:22:55 2015 -0500

    Added getTags.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit efea8bd
Author: Brandon Dalesandro <brandonadalesandro@gmail.com>
Date:   Thu Feb 12 14:10:05 2015 -0800

    updating package.json

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit 3104378
Author: Brandon Dalesandro <brandonadalesandro@gmail.com>
Date:   Thu Feb 12 14:08:29 2015 -0800

    added init

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit 486825e
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Thu Feb 12 14:11:52 2015 -0500

    Remove require of index.js

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 1fd6fa2
Author: Brandon Dalesandro <brandonadalesandro@gmail.com>
Date:   Thu Feb 12 00:22:44 2015 -0800

    added a dependency to recursively make a file structure if it doesn't exist, and added more to the postClone for git init

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit fe069ea
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Mon Feb 9 00:01:11 2015 -0500

    Manually merged clone with index changes in git.js.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit f2d5525
Author: Brandon Dalesandro <brandonadalesandro@gmail.com>
Date:   Sat Feb 7 20:27:44 2015 -0800

    moved postClone to git/clone & changed clone dir

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit e2ecabe
Author: Brandon Dalesandro <brandonadalesandro@gmail.com>
Date:   Sat Feb 7 20:01:29 2015 -0800

    added error handling to POST git/clone

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit 7f64a4c
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Sat Feb 7 19:25:55 2015 -0500

    Added more code to status.js and made changes to git.js.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 407cfdd
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Sat Feb 7 16:29:52 2015 -0500

    Continued refactoring .js files in git directory, updated nodegit
    version for git status.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 67d97df
Author: Brandon Dalesandro <brandonadalesandro@gmail.com>
Date:   Fri Feb 6 20:42:53 2015 -0800

    added basic clone implementation

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit 1cceeb4
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Fri Feb 6 18:53:42 2015 -0500

    Refactored git.js to include config (unfinished), status (unfinished),
    and remotes (finished).

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit e63162d
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Fri Feb 6 18:26:30 2015 -0500

    Refactor code for git clone to clean up git.js

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit ae52263
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Sun Feb 1 19:38:04 2015 -0800

    Added more routes, beginning to look at branches.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit cf63718
Author: Lef Ioannidis <elefthei@mit.edu>
Date:   Sun Feb 1 22:16:10 2015 -0500

    Added Remove Clone Functionality.

    Signed-off-by: Lef Ioannidis <elefthei@mit.edu>

commit 6b6e6c0
Author: Brandon Dalesandro <brandonadalesandro@gmail.com>
Date:   Sun Feb 1 19:11:02 2015 -0800

    extended test cases

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit 45dd4d6
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Sun Feb 1 17:39:22 2015 -0800

    Tried adding config and status routes.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 16bb79c
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Sun Feb 1 15:06:24 2015 -0800

    Repository button on git displays location.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit e1a227d
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Sun Feb 1 14:51:52 2015 -0800

    Git remote URL properly added to response.

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 1d4681b
Author: Mei-Vern Then <mt2837@columbia.edu>
Date:   Sun Feb 1 14:22:00 2015 -0800

    Used getRemote to get remote URL in git.js

    Signed-off-by: Mei-Vern Then <mt2837@columbia.edu>

commit 1d88a3d
Author: Brandon Dalesandro <brandonadalesandro@gmail.com>
Date:   Sun Feb 1 14:29:09 2015 -0800

    Separated the tests for the nodegit api, and our git api

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit f93486d
Author: Brandon Dalesandro <brandonadalesandro@gmail.com>
Date:   Sun Feb 1 13:30:30 2015 -0800

    Added sample test case.

    Signed-off-by: Brandon Dalesandro <brandonadalesandro@gmail.com>

commit 6c820e8
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Sun Feb 1 11:47:04 2015 -0800

    Try sending back response.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit d7004d2
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Sun Feb 1 10:52:19 2015 -0800

    Recursively walk workspace to find git repos, print out master commit of each repo.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit 43c73e0
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Sun Feb 1 09:31:19 2015 -0800

    Upgrade connect to fix invalid json issue due to content-type: application/json from the client on GET requests. Add dummy response.

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit ee2fb8d
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Sat Jan 31 16:51:38 2015 -0800

    Return orion.conf to its former glory

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit daca248
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Sat Jan 31 16:42:15 2015 -0800

    Add some scaffolding for git routes

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit fb256fa
Author: Lef Ioannidis <elefthei@mit.edu>
Date:   Sat Jan 31 18:55:16 2015 -0500

    Merged conflicting orion.conf files

    Signed-off-by: Lef Ioannidis <elefthei@mit.edu>

commit 7fd092e
Author: Albert Cui <aqc2109@columbia.edu>
Date:   Sat Jan 31 15:51:48 2015 -0800

    enable git plugin

    Signed-off-by: Albert Cui <aqc2109@columbia.edu>

commit b50cc80
Author: Lef Ioannidis <elefthei@mit.edu>
Date:   Sat Jan 31 17:55:00 2015 -0500

    Added nodegit v.0.2.7 dependency

    Signed-off-by: Lef Ioannidis <elefthei@mit.edu>

=======================================================================

Also-by: Mei-Vern Then <mt2837@columbia.edu>
Also-by: Brandon Dalesandro <brandonadalesandro@gmail.com>
Also-by: Lef Ioannidis <elefthei@mit.edu>

Signed-off-by: Albert Cui <aqc2109@columbia.edu>
  • Loading branch information
albertcui authored and mamacdon committed Aug 5, 2015
1 parent 5f79148 commit 6637e63
Show file tree
Hide file tree
Showing 18 changed files with 3,051 additions and 7 deletions.
28 changes: 28 additions & 0 deletions modules/orionode/index.js
Expand Up @@ -9,14 +9,17 @@
* IBM Corporation - initial API and implementation
*******************************************************************************/
/*jslint node:true*/
/*eslint-env node */
var connect = require('connect'),
path = require('path'),
AppContext = require('./lib/node_apps').AppContext,
orionFile = require('./lib/file'),
orionNode = require('./lib/node'),
orionWorkspace = require('./lib/workspace'),
orionGit = require('./lib/git'),
orionNodeStatic = require('./lib/orionode_static'),
orionStatic = require('./lib/orion_static'),
orionTasks = require('./lib/tasks'),
term = require('term.js');

var LIBS = path.normalize(path.join(__dirname, 'lib/')),
Expand All @@ -42,6 +45,26 @@ function startServer(options) {
orionClientRoot: ORION_CLIENT,
maxAge: options.maxAge
}))
.use(function(req, res, next) {

// Fake login response
if (req.url === "/login" && req.method === "POST") {
console.log("login")
return res.end(JSON.stringify({
"EmailConfirmed": false,
"FullName": "anonymous",
"HasPassword": true,
"LastLoginTimestamp": "1416865840208",
"Location": "/workspace/orionode",
"UserName": "anonymous"
}))
}

next();
})
.use(orionTasks.orionTasksAPI({
root: '/task'
}))
// API handlers
.use(orionFile({
root: '/file',
Expand All @@ -52,6 +75,11 @@ function startServer(options) {
fileRoot: '/file',
workspaceDir: workspaceDir
}))
.use(orionGit({
root: '/gitapi',
fileRoot: '/file',
workspaceDir: workspaceDir
}))
.use(orionNode({
appContext: appContext,
root: '/node'
Expand Down
154 changes: 154 additions & 0 deletions modules/orionode/lib/git.js
@@ -0,0 +1,154 @@
/*******************************************************************************
* Copyright (c) 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0
* (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
* License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
/*eslint-env node*/

var connect = require('connect');
var fs = require('fs');
var util = require('util');
var api = require('./api'), writeError = api.writeError;
var fileUtil = require('./fileUtil');
var resource = require('./resource');
var add = require('./git/add');
var clone = require('./git/clone');
var remotes = require('./git/remotes');
var branches = require('./git/branches');
var status = require('./git/status');
var config = require('./git/config');
var commit = require('./git/commit');
var tags = require('./git/tags');
var stash = require('./git/stash');
var blame = require('./git/blame');
var diff = require('./git/diff');
var rmdir = require('rimraf');
var path = require('path');
var url = require('url');
var redirect = require('connect-redirection');

module.exports = function(options) {
var workspaceRoot = options.root;
var workspaceDir = options.workspaceDir;
var fileRoot = options.fileRoot;
if (!workspaceRoot) { throw 'options.root path required'; }
return connect()
.use(connect.json())
.use(redirect())
.use(function(req, res, next) {
console.log(req.method + " " + req.url);
next();
})
.use(resource(workspaceRoot, {
GET: function(req, res, next, rest) {
var query = url.parse(req.url, true).query;
if (rest === '') {
console.log("nope");
} else if (rest.indexOf("clone/workspace/") === 0) {
clone.getClone(workspaceDir, fileRoot, req, res, next, rest);
} else if (rest.indexOf("remote/file/") === 0) {
remotes.getRemotes(workspaceDir, fileRoot, req, res, next, rest);
} else if (rest.indexOf("remote/") === 0 ) {
var remote = rest.replace("remote/", "").substring(0, rest.lastIndexOf("/file/")-"/file/".length-1);
if (remote.indexOf("/") === -1) {
remotes.getRemotesBranches(workspaceDir, fileRoot, req, res, next, rest);
}
else {
remotes.getRemotesBranchDetail(workspaceDir, fileRoot, req, res, next, rest);
}
} else if (rest.indexOf("branch/file/")===0) {
branches.getBranches(workspaceDir, fileRoot, req, res, next, rest);
} else if (rest.indexOf("branch/")===0) {
branches.getBranchMetadata(workspaceDir, fileRoot, req, res, next, rest);
} else if (rest.indexOf("status/file/") === 0) {
status.getStatus(workspaceDir, fileRoot, req, res, next, rest);
} else if (rest.indexOf("config/clone/file/") === 0) {
config.getConfig(workspaceDir, fileRoot, req, res, next, rest);
} else if (rest.indexOf("config/") === 0) {
config.getAConfig(workspaceDir, fileRoot, req, res, next, rest);
} else if (rest.indexOf("index/file/") === 0) {
// I think this is working, but I'm not 100%, leave it out for now.
add.getFileIndex(workspaceDir, fileRoot, req, res, next, rest);
} else if (rest.indexOf("tag/file/") === 0) {
tags.getTags(workspaceDir, fileRoot, req, res, next, rest);
} else if (rest.indexOf("stash/file") === 0) {
stash.getStash(workspaceDir, fileRoot, req, res, next, rest);
} else if (rest.indexOf("blame/") === 0) {
blame.getBlame(workspaceDir, fileRoot, req, res, next, rest);
} else if (rest.indexOf("commit/") === 0) {
commit.getCommit(workspaceDir, fileRoot, req, res, next, rest);
} else if (rest.indexOf("diff/Default/file/") === 0) {
var diffOnly = query.parts === 'diff';
var uriOnly = query.parts === 'uris';

diff.getDiffBetweenWorkingTreeAndHead(workspaceDir, fileRoot, req, res, next, rest, diffOnly, uriOnly);
} else if (rest.indexOf("diff/Cached/file/") === 0) {
var diffOnly = query.parts === 'diff';
var uriOnly = query.parts === 'uris';

diff.getDiffBetweenIndexAndHead(workspaceDir, fileRoot, req, res, next, rest, diffOnly, uriOnly);
} else if (rest.indexOf("diff/") === 0) {
var diffOnly = query.parts === 'diff';
var uriOnly = query.parts === 'uris';

diff.getDiffBetweenTwoCommits(workspaceDir, fileRoot, req, res, next, rest, diffOnly, uriOnly)
} else {
writeError(403, res);
}
},
POST: function(req, res, next, rest) {
if (rest.indexOf("clone/") === 0){
clone.postInit(workspaceDir, fileRoot, req, res, next, rest);
} else if(rest.indexOf("index/") === 0) {
add.postStage(workspaceDir, fileRoot, req, res, next, rest);
} else if (rest.indexOf("config/") === 0) {
config.postConfig(workspaceDir, fileRoot, req, res, next, rest);
} else if (rest.indexOf("commit/") === 0) {
commit.postCommit(workspaceDir, fileRoot, req, res, next, rest);
} else if (rest.indexOf("branch/") === 0) {
branches.createBranch(workspaceDir, fileRoot, req, res, next, rest);
} else if (rest.indexOf("diff/") === 0) {
diff.getDiffLocation(workspaceDir, fileRoot, req, res, next, rest);
} else if (rest.indexOf("remote/file/") === 0) {
remotes.addRemote(workspaceDir, fileRoot, req, res, next, rest);
} else if (rest.indexOf("remote/") === 0) {
remotes.postRemote(workspaceDir, fileRoot, req, res, next, rest);
} else {
writeError(403, res);
}
},
PUT: function(req, res, next, rest) {
if (rest.indexOf("index/") === 0) {
add.putStage(workspaceDir, fileRoot, req, res, next, rest);
} else if (rest.indexOf("config/") === 0) {
config.putConfig(workspaceDir, fileRoot, req, res, next, rest);
} else {
// Would 501 be more appropriate?
writeError(403, res);
}
},
DELETE: function(req, res, next, rest) {
if(rest.indexOf("clone/file/") === 0) {
var configPath = rest.replace("clone/file", "");
var rmdir = require('rimraf');
rmdir(workspaceDir.concat(configPath), function() {
res.statusCode = 200;
res.end();
});
} else if (rest.indexOf("tag/") === 0) {
tags.deleteTags(workspaceDir, fileRoot, req, res, next, rest);
} else if (rest.indexOf("branch/") === 0) {
branches.deleteBranch(workspaceDir, fileRoot, req, res, next, rest);
} else if (rest.indexOf("remote/") === 0) {
remotes.deleteRemote(workspaceDir, fileRoot, req, res, next, rest);
} else {
writeError(403, res);
}
}
}));
};
147 changes: 147 additions & 0 deletions modules/orionode/lib/git/add.js
@@ -0,0 +1,147 @@
/*******************************************************************************
* Copyright (c) 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0
* (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
* License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
/*eslint-env node */
var api = require('../api'), writeError = api.writeError;
var git = require('nodegit');
var async = require('async');
var path = require("path");

function getFileIndex(workspaceDir, fileRoot, req, res, next, rest) {
var repo;
var index;
var result = "";

var repoPath = rest.replace("index/file/", "");
var file = repoPath.substring(repoPath.indexOf("/")+1);
repoPath = repoPath.substring(0, repoPath.indexOf("/"));
repoPath = api.join(workspaceDir, repoPath);

git.Repository.open(repoPath)
.then(function(repoResult) {
repo = repoResult;
return repo;
})
.then(function(repo) {
return repo.openIndex();
})
.then(function(indexResult) {
index = indexResult;
return index.read(1);
})
.then(function() {
var indexEntry = index.getByPath(file);
return git.Blob.lookup(repo, indexEntry.id)
})
.then(function(blob) {
res.write(blob.toString());
res.statusCode = 200;
res.end();
})
.catch(function(err) {
console.log(err);
writeError(404, res);
});
}

// Stage files
function putStage(workspaceDir, fileRoot, req, res, next, rest) {
var repo;
var index;

var repoPath = rest.replace("index/file/", "");
var filePath = repoPath.substring(repoPath.indexOf("/")+1);
repoPath = repoPath.indexOf("/") === -1 ? repoPath : repoPath.substring(0, repoPath.indexOf("/"));
var fileDir = repoPath;
repoPath = api.join(workspaceDir, repoPath);

git.Repository.open(repoPath)
.then(function(repoResult) {
repo = repoResult;
return repoResult;
})
.then(function(repo) {
return repo.openIndex();
})
.then(function(indexResult) {
index = indexResult;
return index.read(1);
})
.then(function() {
if (req.body.Path) {
req.body.Path.forEach(function(path) {
index.addByPath(path);
})
} else {
return index.addByPath(filePath);
}
})
.then(function() {
// this will write both files to the index
return index.write();
})
.then(function() {
return index.writeTree();
})
.done(function(tree) {
res.statusCode = 200;
res.end();
});
}

// unstage files
function postStage(workspaceDir, fileRoot, req, res, next, rest) {
var repo;
var index;

var repoPath = rest.replace("index/file/", "");
var filePath = repoPath.substring(repoPath.indexOf("/")+1);
repoPath = repoPath.indexOf("/") === -1 ? repoPath : repoPath.substring(0, repoPath.indexOf("/"));
var fileDir = repoPath;
repoPath = api.join(workspaceDir, repoPath);

git.Repository.open(repoPath)
.then(function(repoResult) {
repo = repoResult;
return repoResult;
})
.then(function(repo) {
return git.Reference.nameToId(repo, "HEAD");
})
.then(function(head) {
return repo.getCommit(head);
})
.then(function(commit) {
if (req.body.Path) {
if (typeof req.body.Path == "string") {
return git.Reset.default(repo, commit, req.body.Path);
} else {
req.body.Path.forEach(function(path) {
return git.Reset.default(repo, commit, path)
})
}
} else if (req.body.Reset) {
return git.Reset.default(repo, commit, ".")
} else {
return git.Reset.default(repo, commit, filePath)

}
})
.done(function() {
res.statusCode = 200;
res.end();
});
}

module.exports = {
putStage: putStage,
postStage: postStage,
getFileIndex: getFileIndex
};

0 comments on commit 6637e63

Please sign in to comment.