Skip to content

Commit bfa4973

Browse files
committed
get Info based on selected Author
1 parent 37b66d9 commit bfa4973

File tree

4 files changed

+13
-35
lines changed

4 files changed

+13
-35
lines changed

src/dataSource.ts

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ export class DataSource extends Disposable {
161161
* @param stashes An array of all stashes in the repository.
162162
* @returns The commits in the repository.
163163
*/
164-
public getCommits(repo: string, branches: ReadonlyArray<string> | null, maxCommits: number, showTags: boolean, showRemoteBranches: boolean, includeCommitsMentionedByReflogs: boolean, onlyFollowFirstParent: boolean, commitOrdering: CommitOrdering, remotes: ReadonlyArray<string>, hideRemotes: ReadonlyArray<string>, stashes: ReadonlyArray<GitStash>): Promise<GitCommitData> {
164+
public getCommits(repo: string, branches: ReadonlyArray<string> | null, authors: ReadonlyArray<string> | null, maxCommits: number, showTags: boolean, showRemoteBranches: boolean, includeCommitsMentionedByReflogs: boolean, onlyFollowFirstParent: boolean, commitOrdering: CommitOrdering, remotes: ReadonlyArray<string>, hideRemotes: ReadonlyArray<string>, stashes: ReadonlyArray<GitStash>): Promise<GitCommitData> {
165165
const config = getConfig();
166166
return Promise.all([
167-
this.getLog(repo, branches, maxCommits + 1, showTags && config.showCommitsOnlyReferencedByTags, showRemoteBranches, includeCommitsMentionedByReflogs, onlyFollowFirstParent, commitOrdering, remotes, hideRemotes, stashes),
167+
this.getLog(repo, branches, authors, maxCommits + 1, showTags && config.showCommitsOnlyReferencedByTags, showRemoteBranches, includeCommitsMentionedByReflogs, onlyFollowFirstParent, commitOrdering, remotes, hideRemotes, stashes),
168168
this.getRefs(repo, showRemoteBranches, config.showRemoteHeads, hideRemotes).then((refData: GitRefData) => refData, (errorMessage: string) => errorMessage)
169169
]).then(async (results) => {
170170
let commits: GitCommitRecord[] = results[0], refData: GitRefData | string = results[1], i;
@@ -288,8 +288,6 @@ export class DataSource extends Disposable {
288288
const consolidatedConfigs = results[0], localConfigs = results[1], globalConfigs = results[2], authors = results[3];
289289

290290
const branches: GitRepoConfigBranches = {};
291-
// const authors:ReadonlyArray<GitRepoConfigAuthor> = [];
292-
console.warn(authors);
293291
Object.keys(localConfigs).forEach((key) => {
294292
if (key.startsWith('branch.')) {
295293
if (key.endsWith('.remote')) {
@@ -307,30 +305,6 @@ export class DataSource extends Disposable {
307305
}
308306
}
309307
});
310-
console.warn({config: {
311-
branches: branches,
312-
authors,
313-
diffTool: getConfigValue(consolidatedConfigs, GitConfigKey.DiffTool),
314-
guiDiffTool: getConfigValue(consolidatedConfigs, GitConfigKey.DiffGuiTool),
315-
pushDefault: getConfigValue(consolidatedConfigs, GitConfigKey.RemotePushDefault),
316-
remotes: remotes.map((remote) => ({
317-
name: remote,
318-
url: getConfigValue(localConfigs, 'remote.' + remote + '.url'),
319-
pushUrl: getConfigValue(localConfigs, 'remote.' + remote + '.pushurl')
320-
})),
321-
user: {
322-
name: {
323-
local: getConfigValue(localConfigs, GitConfigKey.UserName),
324-
global: getConfigValue(globalConfigs, GitConfigKey.UserName)
325-
},
326-
email: {
327-
local: getConfigValue(localConfigs, GitConfigKey.UserEmail),
328-
global: getConfigValue(globalConfigs, GitConfigKey.UserEmail)
329-
}
330-
}
331-
},
332-
error: null
333-
});
334308
return {
335309
config: {
336310
branches: branches,
@@ -357,7 +331,6 @@ export class DataSource extends Disposable {
357331
error: null
358332
};
359333
}).catch((errorMessage) => {
360-
console.log(errorMessage);
361334
return { config: null, error: errorMessage };
362335
});
363336
}
@@ -1570,11 +1543,16 @@ export class DataSource extends Disposable {
15701543
* @param stashes An array of all stashes in the repository.
15711544
* @returns An array of commits.
15721545
*/
1573-
private getLog(repo: string, branches: ReadonlyArray<string> | null, num: number, includeTags: boolean, includeRemotes: boolean, includeCommitsMentionedByReflogs: boolean, onlyFollowFirstParent: boolean, order: CommitOrdering, remotes: ReadonlyArray<string>, hideRemotes: ReadonlyArray<string>, stashes: ReadonlyArray<GitStash>) {
1546+
private getLog(repo: string, branches: ReadonlyArray<string> | null, authors: ReadonlyArray<string> | null, num: number, includeTags: boolean, includeRemotes: boolean, includeCommitsMentionedByReflogs: boolean, onlyFollowFirstParent: boolean, order: CommitOrdering, remotes: ReadonlyArray<string>, hideRemotes: ReadonlyArray<string>, stashes: ReadonlyArray<GitStash>) {
15741547
const args = ['-c', 'log.showSignature=false', 'log', '--max-count=' + num, '--format=' + this.gitFormatLog, '--' + order + '-order'];
15751548
if (onlyFollowFirstParent) {
15761549
args.push('--first-parent');
15771550
}
1551+
if(authors !== null) {
1552+
for (let i = 0; i < authors.length; i++) {
1553+
args.push(`--author=${authors[i]}`);
1554+
}
1555+
}
15781556
if (branches !== null) {
15791557
for (let i = 0; i < branches.length; i++) {
15801558
args.push(branches[i]);
@@ -1593,7 +1571,6 @@ export class DataSource extends Disposable {
15931571
});
15941572
}
15951573
}
1596-
15971574
// Add the unique list of base hashes of stashes, so that commits only referenced by stashes are displayed
15981575
const stashBaseHashes = stashes.map((stash) => stash.baseHash);
15991576
stashBaseHashes.filter((hash, index) => stashBaseHashes.indexOf(hash) === index).forEach((hash) => args.push(hash));
@@ -1602,6 +1579,8 @@ export class DataSource extends Disposable {
16021579
}
16031580
args.push('--');
16041581

1582+
1583+
16051584
return this.spawnGit(args, repo, (stdout) => {
16061585
let lines = stdout.split(EOL_REGEX);
16071586
let commits: GitCommitRecord[] = [];

src/gitGraphView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ export class GitGraphView extends Disposable {
409409
command: 'loadCommits',
410410
refreshId: msg.refreshId,
411411
onlyFollowFirstParent: msg.onlyFollowFirstParent,
412-
...await this.dataSource.getCommits(msg.repo, msg.branches, msg.maxCommits, msg.showTags, msg.showRemoteBranches, msg.includeCommitsMentionedByReflogs, msg.onlyFollowFirstParent, msg.commitOrdering, msg.remotes, msg.hideRemotes, msg.stashes)
412+
...await this.dataSource.getCommits(msg.repo, msg.branches, msg.authors, msg.maxCommits, msg.showTags, msg.showRemoteBranches, msg.includeCommitsMentionedByReflogs, msg.onlyFollowFirstParent, msg.commitOrdering, msg.remotes, msg.hideRemotes, msg.stashes)
413413
});
414414
break;
415415
case 'loadConfig':

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,7 @@ export interface RequestLoadCommits extends RepoRequest {
907907
readonly command: 'loadCommits';
908908
readonly refreshId: number;
909909
readonly branches: ReadonlyArray<string> | null; // null => Show All
910+
readonly authors: ReadonlyArray<string> | null; // null => Show All
910911
readonly maxCommits: number;
911912
readonly showTags: boolean;
912913
readonly showRemoteBranches: boolean;

web/main.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ class GitGraphView {
217217
}
218218

219219
private loadRepo(repo: string) {
220-
console.warn('loadRepro');
221220
this.currentRepo = repo;
222221
this.currentRepoLoading = true;
223222
this.showRemoteBranchesElem.checked = getShowRemoteBranches(this.gitRepos[this.currentRepo].showRemoteBranchesV2);
@@ -296,7 +295,6 @@ class GitGraphView {
296295

297296
// Set up branch dropdown options
298297
this.branchDropdown.setOptions(this.getBranchOptions(true), this.currentBranches);
299-
console.warn('test2');
300298
this.authorDropdown.setOptions(this.getAuthorOptions(), this.currentAuthors);
301299

302300
// Remove hidden remotes that no longer exist
@@ -646,7 +644,7 @@ class GitGraphView {
646644
repo: this.currentRepo,
647645
refreshId: ++this.currentRepoRefreshState.loadCommitsRefreshId,
648646
branches: this.currentBranches === null || (this.currentBranches.length === 1 && this.currentBranches[0] === SHOW_ALL_BRANCHES) ? null : this.currentBranches,
649-
// authors: this.currentBranches === null || (this.currentBranches.length === 1 && this.currentBranches[0] === SHOW_ALL_BRANCHES) ? null : this.currentBranches,
647+
authors: this.currentAuthors === null || (this.currentAuthors.length === 1 && this.currentAuthors[0] === SHOW_ALL_BRANCHES) ? null : this.currentAuthors,
650648
maxCommits: this.maxCommits,
651649
showTags: getShowTags(repoState.showTags),
652650
showRemoteBranches: getShowRemoteBranches(repoState.showRemoteBranchesV2),

0 commit comments

Comments
 (0)