oceanbit / GitShark

🦈 A Git client to surf through your repos on mobile
https://gitshark.dev
Mozilla Public License 2.0
136 stars 9 forks source link

Add fetch after intial clone #33

Closed crutchcorn closed 4 years ago

crutchcorn commented 4 years ago

Currently, when we do a clone, we do not receive upstream branch names due to isomorphic-gits handling of cloning. During the cloning process, isomorphic-git must not do a fetch in order to receive the remote branch names, as a listBranches command right after cloning does not return the expected results, but after a fetch, we do.

> git.listBranches({fs, dir, remote: 'origin'}).then(console.log)
Promise { <pending> }
> [ 'HEAD', 'integration' ]
> git.fetch({fs, http, dir, remote: 'origin'}).then(console.log)
Promise { <pending> }
> {
  defaultBranch: 'refs/heads/integration',
  fetchHead: '1f471a252544c4ddb122d43a4822f51d7b532ac0',
  fetchHeadDescription: "branch 'integration' of https://github.com/unicorn-utterances/batteries-not-included.git",
  headers: {
    server: 'GitHub Babel 2.0',
    'content-type': 'application/x-git-upload-pack-result',
    'transfer-encoding': 'chunked',
    expires: 'Fri, 01 Jan 1980 00:00:00 GMT',
    pragma: 'no-cache',
    'cache-control': 'no-cache, max-age=0, must-revalidate',
    vary: 'Accept-Encoding',
    'x-github-request-id': 'F8E6:3941:20A221:2D6F1C:5F10F9D6',
    'x-frame-options': 'DENY',
    connection: 'close'
  },
  packfile: 'objects/pack/pack-eb585ed66a7c2b3b6e4bcc47549ccb143b536561.pack'
}
> git.listBranches({fs, dir, remote: 'origin'}).then(console.log)
Promise { <pending> }
> [
  'HEAD',
  'dependabot/npm_and_yarn/standard-version-8.0.1',
  'integration',
  'tablize',
  'test'
]