Isomorphic-git: Error when pushing without "ref"

Created on 20 Mar 2018  路  7Comments  路  Source: isomorphic-git/isomorphic-git

The documentation says that push doesn't require a ref but I get the following if I don't specify it:

Cannot read property 'startsWith' of undefined
    at Object.push (commands.js:841)

The error goes away if I pass a ref.

Thanks for this amazing library

bug

Most helpful comment

@TomasHubelbauer I can create a PR with update to push.js

All 7 comments

Documentation says

Which branch to push. By default this is the currently checked out branch.

I would like to take a look at this this weekend, so I am assigning myself (hopefully that's okay?). If you get to it sooner or just want to do it yourself, please feel free to unassign me @wmhilton.

That's amazingly OK to assign yourself! To figure out what the current branch is you can use GitRefManager.resolve on 'HEAD' with a depth limit of... 2, I think? I should probably add a helper function to GitRefManager for getting the current branch.

I use code like this to get the branch:

    async function gitBranch(filepath) {
        try {
            var dir = await git.findRoot({fs, filepath});
            var ref = await git.resolveRef({fs, dir, ref: 'HEAD', depth: 1});
            return ref.match(/ref: refs\/heads\/(.*)/)[1];
        } catch(e) {
        }
    }

Actually @jcubic I am unable to work on this at the moment due to time reasons, would you like to take a shot yourself?

@TomasHubelbauer I can create a PR with update to push.js

:tada: This issue has been resolved in version 0.14.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

westurner picture westurner  路  7Comments

willstott101 picture willstott101  路  4Comments

tomatoaiu picture tomatoaiu  路  7Comments

creationix picture creationix  路  4Comments

pickledish picture pickledish  路  3Comments