Skip to content

Commit

Permalink
remotes: actually fetch when clicking fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
wmertens committed Oct 11, 2022
1 parent 1292a39 commit 7f2bac3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
3 changes: 1 addition & 2 deletions components/remotes/remotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@ class RemotesViewModel {
ungit.logger.debug('remotes.fetch() triggered');

try {
const tagPromise = this.server.getPromise('/remote/tags', {
await this.server.postPromise('/fetch', {
path: this.repoPath(),
remote: this.currentRemote(),
});
programEvents.dispatch({ event: 'remote-tags-update', tags: await tagPromise });
if (!this.server.isInternetConnected) {
this.server.isInternetConnected = true;
}
Expand Down
2 changes: 1 addition & 1 deletion source/git-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ exports.registerApi = (env) => {
jw(async (req, res) => {
if (req.query.remoteFetch) {
if (res.setTimeout) res.setTimeout(tenMinTimeoutMs);
await req.repo.remoteAllFetch().catch((err) => {
await req.repo.remoteAllFetch(config.autoPruneOnFetch).catch((err) => {
console.warn('ignoring fetch error', err);
});
}
Expand Down
9 changes: 5 additions & 4 deletions source/nodegit.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,24 +275,25 @@ class NGWrap {
*/
async remoteFetch(remoteName, refs = null, prune) {
const remote = await this.r.getRemote(remoteName).catch(normalizeError);
// TODO use credentialshelper
await remote.fetch(
refs,
{
callbacks: {
credentials: (url, userName) => nodegit.Cred.sshKeyFromAgent(userName),
// TODO use credentialshelper
// @ts-ignore -- Credential does exist, bad typing
credentials: (url, userName) => nodegit.Credential.sshKeyFromAgent(userName),
},
prune: prune ? nodegit.Fetch.PRUNE.GIT_FETCH_PRUNE : undefined,
},
undefined
);
}

async remoteAllFetch() {
async remoteAllFetch(prune) {
const remotes = await this.getRemotes();
// making calls serially as credential helpers may get confused to which cred to get.
for (const name of remotes) {
await this.remoteFetch(name);
await this.remoteFetch(name, null, prune);
}
}

Expand Down

0 comments on commit 7f2bac3

Please sign in to comment.