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

Needed pull example or help with code · Issue #341 · nodegit/nodegit · GitHub

Repository navigation

Needed pull example or help with code #341

Description

Hi

Firstly, thanks for good work.

Is there a chance to provide by you PULL example (git fetch followed by git merge FETCH_HEAD) or can you help me how should I change below code to achieve "git merge FETCH_HEAD"?

I used your fetch example and it worked, my repo is in this stage:

"Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
nothing to commit, working directory clean"

I won't have any changes in repository in future and don't have now, so I'm looking for method that won't create commit and won't force me to push 'merge commit'.
I was trying to modify your merge-cleanly example, but it creates commit, so it's not perfect for me (BTW don't know if this correct, because source tree shows history strange, maybe something with date of commit 1973-11-29)

    var repo;
    var localReference, ourCommit;
    var remoteReference, theirCommit;
    var ourSignature = nodegit.Signature.create("user test", "user@test.com", 123456789, 60);

    Repository.open("master")
        .then(function(repository) {
            repo = repository;
            return repo.getReference('refs/remotes/origin/master');
        }).then(function(reference) {
            console.log(reference.target());
            remoteReference = reference;
            return repo.getReference('refs/heads/master');
        }).then(function(reference) {
            console.log(reference.target());
            localReference = reference;
            return repo.getCommit(localReference.target());
        }).then(function(commit) {
            ourCommit = commit;
            return repo.getCommit(remoteReference.target());
        }).then(function(commit) {
            theirCommit = commit;
            return Merge.commits(repo, ourCommit, theirCommit);
        }).then(function(index) {
            if (!index.hasConflicts()) {
                index.write();
                return index.writeTreeTo(repo);
            }
        }).then(function(oid) {
            return repo.createCommit('refs/heads/master', ourSignature, ourSignature, 'we merged their commit', oid, [ourCommit, theirCommit]);
        })
        .done(function(commitId) {
            console.log('New Commit: ', commitId);
            console.log("It worked!");
        },
        function() {
            console.log("It failed :( !");
        });

Thanks

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