var express = require('express');
var Git = require("nodegit");
var router = express.Router();
var token = process.env.GITHUB_TOKEN;

router.post('/issues', function(req, res, next) {
  Git.Clone("https://" + token + ":x-oauth-basic@github.com/kewang/information-people", "./tmp", {
    checkoutBranch: "gh-pages"
  }).then(function(repo){
    console.log("getHeadCommit");

    return repo.getHeadCommit();
  }).then(function(commit){
    console.log("getEntry");

    return commit.getEntry("index.htm");
  }).then(function(entry){
    console.log("getBlob");

    return entry.getBlob();
  }).then(function(blob){
    var str = String(blob);

    console.log(str);

    return res.json(str);
  });
});

module.exports = router;

@@ -57,16 +57,40 @@
 egit%22);%0A
+var fs = require('fs');%0A
 var rout
@@ -116,21 +116,28 @@
 ();%0Avar 
-token
+GITHUB_TOKEN
  = proce
@@ -156,16 +156,87 @@
 B_TOKEN;
+%0Avar FILE_NAME = %22index.htm%22;%0Avar content;%0Avar repo;%0Avar head;%0Avar oid;
 %0A%0Arouter
@@ -308,13 +308,20 @@
 %22 + 
-token
+GITHUB_TOKEN
  + %22
@@ -439,18 +439,48 @@
 ion(repo
-)%7B
+Result)%7B%0A    repo = repoResult;%0A
 %0A    con
@@ -563,16 +563,43 @@
 ion(
-commit)%7B
+headResult)%7B%0A    head = headResult;
 %0A   
@@ -640,14 +640,12 @@
 urn 
-commit
+head
 .get
@@ -650,27 +650,25 @@
 etEntry(
-%22index.htm%22
+FILE_NAME
 );%0A  %7D).
@@ -780,52 +780,848 @@
     
-var str = String(blob);%0A%0A    console.log(str
+content = %22DEF%22 + String(blob) + %22ABC%22;%0A%0A    fs.writeFileSync(%22./tmp/%22 + FILE_NAME, content);%0A%0A    return repo.index();%0A  %7D).then(function(index)%7B%0A    index.addByPath(FILE_NAME);%0A    index.write();%0A%0A    return index.writeTree();%0A  %7D).then(function(oidResult)%7B%0A    oid = oidResult;%0A%0A    var author = Git.Signature.now(%22kewang%22, %22cpckewang@gmail.com%22);%0A%0A    return repo.createCommit(%22HEAD%22, author, author, %22Add test%22, oid, %5Bhead%5D);%0A  %7D).then(function(commitId)%7B%0A    console.log(%22New Commit: %22 + commitId);%0A%0A    var remote = repo.getRemote(%22origin%22);%0A%0A    // var remote = Git.Remote.create(repo, %22origin%22, %22https://%22 + GITHUB_TOKEN + %22:x-oauth-basic@github.com/kewang/information-people%22);%0A%0A    console.log(%22remote: %22 + remote);%0A%0A    return remote.push(%5B%22refs/heads/master:refs/heads/master%22%5D);%0A  %7D).done(function()%7B%0A    console.log(%22Push OK%22
 );%0A%0A
@@ -1644,11 +1644,15 @@
 son(
-str
+content
 );%0A 

Add push flow, but test fail