FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Remote object is null · Issue #915 · nodegit/nodegit · GitHub

Repository navigation

Remote object is null #915

Description

Version: 0.11.3

Use repo.getRemote("origin")

It return like {"_55":0,"_87":null,"_28":[]}, and can't use remote.push.

Use Git.Remote.create

If I use Git.Remote.create(repo, "origin", "https://" + GITHUB_TOKEN + ":x-oauth-basic@github.com/abc/def"), it return null.

var express = require('express');
var Git = require("nodegit");
var fs = require('fs');
var router = express.Router();
var GITHUB_TOKEN = process.env.GITHUB_TOKEN;
var FILE_NAME = "index.htm";
var content;
var repo;
var head;
var oid;

router.post('/issues', function(req, res, next) {
  Git.Clone("https://" + GITHUB_TOKEN + ":x-oauth-basic@github.com/abc/def", "./tmp", {
    checkoutBranch: "gh-pages"
  }).then(function(repoResult){
    repo = repoResult;

    console.log("getHeadCommit");

    return repo.getHeadCommit();
  }).then(function(headResult){
    head = headResult;
    console.log("getEntry");

    return head.getEntry(FILE_NAME);
  }).then(function(entry){
    console.log("getBlob");

    return entry.getBlob();
  }).then(function(blob){
    content = "DEF" + String(blob) + "ABC";

    fs.writeFileSync("./tmp/" + FILE_NAME, content);

    return repo.index();
  }).then(function(index){
    index.addByPath(FILE_NAME);
    index.write();

    return index.writeTree();
  }).then(function(oidResult){
    oid = oidResult;

    var author = Git.Signature.now("kewang", "cpckewang@gmail.com");

    return repo.createCommit("HEAD", author, author, "Add test", oid, [head]);
  }).then(function(commitId){
    console.log("New Commit: " + commitId);

    var remote = repo.getRemote("origin");

    // var remote = Git.Remote.create(repo, "origin", "https://" + GITHUB_TOKEN + ":x-oauth-basic@github.com/abc/def");

    console.log("remote: " + remote);

    return remote.push(["refs/heads/master:refs/heads/master"]);
  }).done(function(){
    console.log("Push OK");

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

module.exports = router;

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL