ソースを参照

Adds fetch command to remotes

main
Eric Amodio 6年前
コミット
6857f7c6b5
7個のファイルの変更61行の追加24行の削除
  1. +10
    -0
      package.json
  2. +15
    -1
      src/git/git.ts
  3. +8
    -2
      src/git/gitService.ts
  4. +11
    -9
      src/git/models/repository.ts
  5. +6
    -1
      src/views/nodes/remoteNode.ts
  6. +6
    -6
      src/views/nodes/repositoryNode.ts
  7. +5
    -5
      src/views/viewCommands.ts

+ 10
- 0
package.json ファイルの表示

@ -3552,6 +3552,11 @@
"group": "8_gitlens@2"
},
{
"command": "gitlens.views.fetch",
"when": "viewItem == gitlens:remote",
"group": "inline@97"
},
{
"command": "gitlens.openRepoInRemote",
"when": "viewItem == gitlens:remote",
"group": "inline@98"
@ -3567,6 +3572,11 @@
"group": "1_gitlens@2"
},
{
"command": "gitlens.views.fetch",
"when": "viewItem == gitlens:remote",
"group": "2_gitlens@1"
},
{
"command": "gitlens.views.terminalRemoveRemote",
"when": "viewItem == gitlens:remote",
"group": "8_gitlens@1"

+ 15
- 1
src/git/git.ts ファイルの表示

@ -66,7 +66,9 @@ const GitWarnings = {
noUpstream: /no upstream configured for branch \'(.*?)\'/i,
unknownRevision: /ambiguous argument \'.*?\': unknown revision or path not in the working tree|not stored as a remote-tracking branch/i,
mustRunInWorkTree: /this operation must be run in a work tree/i,
patchWithConflicts: /Applied patch to \'.*?\' with conflicts/i
patchWithConflicts: /Applied patch to \'.*?\' with conflicts/i,
noRemoteRepositorySpecified: /No remote repository specified\./i,
remoteConnectionError: /Could not read from remote repository/i
};
interface GitCommandOptions extends RunOptions {
@ -464,6 +466,18 @@ export class Git {
return git<string>({ cwd: repoPath }, ...params);
}
static fetch(repoPath: string, options: { all?: boolean; remote?: string } = {}) {
const params = ['fetch'];
if (options.remote) {
params.push(options.remote);
}
else if (options.all) {
params.push('--all');
}
return git<string>({ cwd: repoPath }, ...params);
}
static log(repoPath: string, options: { author?: string; maxCount?: number; ref?: string; reverse?: boolean }) {
const params = ['-c', 'diff.renameLimit=0', ...defaultLogParams, '--full-history', '-M', '-m'];
if (options.author) {

+ 8
- 2
src/git/gitService.ts ファイルの表示

@ -466,6 +466,12 @@ export class GitService implements Disposable {
@gate()
@log()
async fetch(repoPath: string, remote?: string) {
return Git.fetch(repoPath, { remote: remote });
}
@gate()
@log()
async fetchAll() {
const repositories = [...(await this.getRepositories())];
if (repositories.length === 0) return;
@ -486,7 +492,7 @@ export class GitService implements Disposable {
increment: (i / total) * 100
});
await repo.fetch(false);
await this.fetch(repo.path);
}
}
);
@ -514,7 +520,7 @@ export class GitService implements Disposable {
increment: (i / total) * 100
});
await repo.pull(false);
await repo.pull({ progress: false });
}
}
);

+ 11
- 9
src/git/models/repository.ts ファイルの表示

@ -225,22 +225,22 @@ export class Repository implements Disposable {
@gate()
@log()
async fetch(progress: boolean = true) {
if (!progress) return this.fetchCore();
async fetch(options: { progress?: boolean; remote?: string } = {}) {
const { progress, ...opts } = { progress: true, ...options };
if (!progress) return this.fetchCore(opts);
await window.withProgress(
{
location: ProgressLocation.Notification,
title: `Fetching ${this.formattedName}...`,
title: `Fetching ${opts.remote ? `${opts.remote} of ` : ''}${this.formattedName}...`,
cancellable: false
},
() => this.fetchCore()
() => this.fetchCore(opts)
);
}
private async fetchCore() {
await commands.executeCommand('git.fetch', this.path);
private async fetchCore(options: { remote?: string } = {}) {
await Container.git.fetch(this.path, options.remote);
this.fireChange(RepositoryChange.Repository);
}
@ -308,7 +308,8 @@ export class Repository implements Disposable {
@gate()
@log()
async pull(progress: boolean = true) {
async pull(options: { progress?: boolean } = {}) {
const { progress } = { progress: true, ...options };
if (!progress) return this.pullCore();
await window.withProgress(
@ -329,7 +330,8 @@ export class Repository implements Disposable {
@gate()
@log()
async push(force: boolean = false, progress: boolean = true) {
async push(options: { force?: boolean; progress?: boolean } = {}) {
const { force, progress } = { progress: true, ...options };
if (!progress) return this.pushCore(force);
await window.withProgress(

+ 6
- 1
src/views/nodes/remoteNode.ts ファイルの表示

@ -4,7 +4,7 @@ import { ViewBranchesLayout } from '../../configuration';
import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { GitRemote, GitRemoteType, GitUri, Repository } from '../../git/gitService';
import { Arrays, Iterables } from '../../system';
import { Arrays, Iterables, log } from '../../system';
import { RepositoriesView } from '../repositoriesView';
import { BranchNode } from './branchNode';
import { BranchOrTagFolderNode } from './branchOrTagFolderNode';
@ -107,4 +107,9 @@ ${this.remote.path} (${this.remote.provider !== undefined ? this.remote.provider
return item;
}
@log()
fetch(options: { progress?: boolean } = {}) {
return this.repo.fetch({ ...options, remote: this.remote.name });
}
}

+ 6
- 6
src/views/nodes/repositoryNode.ts ファイルの表示

@ -167,18 +167,18 @@ export class RepositoryNode extends SubscribeableViewNode {
}
@log()
fetch(progress: boolean = true) {
return this.repo.fetch(progress);
fetch(options: { progress?: boolean; remote?: string } = {}) {
return this.repo.fetch(options);
}
@log()
pull(progress: boolean = true) {
return this.repo.pull(progress);
pull(options: { progress?: boolean } = {}) {
return this.repo.pull(options);
}
@log()
push(force: boolean = false, progress: boolean = true) {
return this.repo.push(force, progress);
push(options: { force?: boolean; progress?: boolean } = {}) {
return this.repo.push(options);
}
@gate()

+ 5
- 5
src/views/viewCommands.ts ファイルの表示

@ -108,10 +108,10 @@ export class ViewCommands implements Disposable {
this._disposable && this._disposable.dispose();
}
private fetch(node: RepositoryNode) {
if (!(node instanceof RepositoryNode)) return;
return node.fetch();
private fetch(node: RemoteNode | RepositoryNode) {
if (node instanceof RemoteNode) return node.fetch();
if (node instanceof RepositoryNode) return node.fetch();
return;
}
private pull(node: RepositoryNode | StatusUpstreamNode) {
@ -129,7 +129,7 @@ export class ViewCommands implements Disposable {
}
if (!(node instanceof RepositoryNode)) return;
return node.push(force);
return node.push({ force: force });
}
private async applyChanges(node: CommitFileNode | StashFileNode | ResultsFileNode) {

読み込み中…
キャンセル
保存