Skip to content

Commit

Permalink
Enable git fetch again
Browse files Browse the repository at this point in the history
Which got removed in FredrikNoren@3b8b973
  • Loading branch information
campersau committed Oct 2, 2024
1 parent a22f2e2 commit dc85031
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
23 changes: 17 additions & 6 deletions components/remotes/remotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,26 @@ class RemotesViewModel {
}

async fetch(options) {
if (!this.currentRemote() || !options.tags) return;
if (!this.currentRemote()) return;
ungit.logger.debug('remotes.fetch() triggered');

try {
const tagPromise = this.server.getPromise('/remote/tags', {
path: this.repoPath(),
remote: this.currentRemote(),
});
programEvents.dispatch({ event: 'remote-tags-update', tags: await tagPromise });
const tagPromise = options.tags
? this.server.getPromise('/remote/tags', {
path: this.repoPath(),
remote: this.currentRemote(),
})
: null;
const fetchPromise = options.nodes
? this.server.getPromise('/fetch', { path: this.repoPath(), remote: this.currentRemote() })
: null;

if (tagPromise) {
programEvents.dispatch({ event: 'remote-tags-update', tags: await tagPromise });
}
if (fetchPromise) {
await fetchPromise;
}
if (!this.server.isInternetConnected) {
this.server.isInternetConnected = true;
}
Expand Down
12 changes: 6 additions & 6 deletions source/git-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ exports.registerApi = (env) => {
}
);

app.post(
app.get(
`${exports.pathPrefix}/fetch`,
ensureAuthenticated,
ensurePathExists,
Expand All @@ -303,18 +303,18 @@ exports.registerApi = (env) => {
if (res.setTimeout) res.setTimeout(tenMinTimeoutMs);

const task = gitPromise({
commands: credentialsOption(req.body.socketId, req.body.remote).concat([
commands: credentialsOption(req.query.socketId, req.query.remote).concat([
'fetch',
config.autoPruneOnFetch ? '--prune' : '',
'--',
req.body.remote,
req.body.ref ? req.body.ref : '',
req.query.remote,
req.query.ref ? req.query.ref : '',
]),
repoPath: req.body.path,
repoPath: req.query.path,
timeout: tenMinTimeoutMs,
});

jsonResultOrFailProm(res, task).finally(emitGitDirectoryChanged.bind(null, req.body.path));
jsonResultOrFailProm(res, task).finally(emitGitDirectoryChanged.bind(null, req.query.path));
}
);

Expand Down
2 changes: 1 addition & 1 deletion test/spec.git-api.remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe('git-api remote', function () {
});

it('fetching in "local2" should work', () => {
return common.post(req, '/fetch', { path: testDirLocal2, remote: 'origin' });
return common.get(req, '/fetch', { path: testDirLocal2, remote: 'origin' });
});

it('log in "local2" should show the branch as one behind', () => {
Expand Down

0 comments on commit dc85031

Please sign in to comment.