question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fetch all branches that match a pattern, ideas for API enhancements, and some bugs that were found

See original GitHub issue

It seems that if a branch has a disconnected history from the main branch, isomorphic-git fails to check it out. You can see the problem on this repository:

const git = require('isomorphic-git')
const fs = require('fs')

;(async () => {
  await git.fetch({
    fs,
    dir: 'isogit',
    url: 'https://github.com/isomorphic-git/isomorphic-git.git',
  })

  await git.checkout({
    fs,
    dir: 'isogit',
    remote: 'origin',
    ref: 'gh-pages',
  })
})()

The error reported is:

Failed to read git object with oid e1593a418bbf61846ce6f044bd01c9cd3cde2004

If you change the ref from gh-pages to develop, it works fine.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:31 (31 by maintainers)

github_iconTop GitHub Comments

1reaction
wmhiltoncommented, Jan 25, 2018

One way is to get a list of branch names in the repository, filter them, then tell fetch to retrieve them.

Another (perhaps alternate) option would be just to have fetch take a collection of include patterns. That’s what I’m essentially doing anyway. Something like: include: [‘v*’, ‘master’].

I’ll probably end up providing both. Some way to do remote reference discovery that essentially exposes GitRemoteHTTP.discover() to get the capabilities and references of a remote, and modifying “git.fetch” to accept an array of refspec patterns. So it’ll probably end up looking a little more verbose, like refspec: ['+refs/heads/master:refs/remotes/origin/master', '+refs/heads/v*:refs/remotes/origin/v/*']. But it will also read the refspecs from .git/config files, which means it’ll understand if you’ve configured your branch to pull from a different remote than ‘origin’ by default, and things like that.

1reaction
wmhiltoncommented, Jan 20, 2018

A remote option for resolveRef;

Ooh! That’s a great idea. That way listBranches and resolveRef work exactly the same way, and it elevates ‘remote’ to a common abstraction. You won’t have to be aware of the filesystem implementation (refs/remotes/${remote}/branch). And now I see I can fix git.checkout by changing it to checkout local branches by default instead of ‘origin’ by default. (A design flaw on my part that made checking out local branches impossible - oops!)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Patterns for Managing Source Code Branches - Martin Fowler
There are several patterns that can allow teams to use branching effectively, concentrating around integrating the work of multiple developers and organizing ...
Read more >
Your configuration specifies to merge with the <branch name ...
Your configuration specifies to merge with the ref 'refs/heads/feature/Sprint4/ABC-123-Branch' from the remote, but no such ref was fetched.
Read more >
Protected branches API - GitLab Docs
Gets a list of protected branches from a project as they are defined in the UI. ... instead of the exact name of...
Read more >
GitHub REST API Tutorial - REST API Support In GitHub
This GitHub Tutorial will explain how to use REST API for various actions to GET, PUT, POST, PATCH, DELETE data using the CURL...
Read more >
Changelog - The GitHub Blog
Code security enablement settings on the list organization repositories REST API ... You can now view ( GET ) the security feature enablement...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found