Skip to content

Commit

Permalink
mhutchie#462 Renamed "Pipeline Status" to "CI/CD Status"
Browse files Browse the repository at this point in the history
  • Loading branch information
keydepth committed Mar 7, 2021
1 parent 008c80d commit c97c255
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 123 deletions.
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -477,12 +477,17 @@
"Commit": {
"type": "boolean",
"title": "Visibility of the Commit column"
},
"CIDI": {
"type": "boolean",
"title": "Visibility of the CI/DI Status column"
}
},
"default": {
"Date": true,
"Author": true,
"Commit": true
"Commit": true,
"CIDI": true
},
"description": "An object specifying the default visibility of the Date, Author & Commit columns. Example: {\"Date\": true, \"Author\": true, \"Commit\": true}"
},
Expand Down
6 changes: 3 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ class Config {
*/
get defaultColumnVisibility(): DefaultColumnVisibility {
let obj: any = this.config.get('defaultColumnVisibility', {});
if (typeof obj === 'object' && obj !== null && typeof obj['Date'] === 'boolean' && typeof obj['Author'] === 'boolean' && typeof obj['Commit'] === 'boolean' && typeof obj['Pipeline'] === 'boolean') {
return { author: obj['Author'], commit: obj['Commit'], date: obj['Date'], pipeline: obj['Pileline']};
if (typeof obj === 'object' && obj !== null && typeof obj['Date'] === 'boolean' && typeof obj['Author'] === 'boolean' && typeof obj['Commit'] === 'boolean' && typeof obj['CIDI'] === 'boolean') {
return { author: obj['Author'], commit: obj['Commit'], date: obj['Date'], cidi: obj['CIDI']};
} else {
return { author: true, commit: true, date: true, pipeline: true };
return { author: true, commit: true, date: true, cidi: true };
}
}

Expand Down
72 changes: 36 additions & 36 deletions src/dataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as vscode from 'vscode';
import { AskpassEnvironment, AskpassManager } from './askpass/askpassManager';
import { getConfig } from './config';
import { Logger } from './logger';
import { CommitOrdering, DateType, DeepWriteable, ErrorInfo, GitCommit, GitCommitDetails, GitCommitStash, GitConfigLocation, GitFileChange, GitFileStatus, GitPipelinesData, GitPushBranchMode, GitRepoConfig, GitRepoConfigBranches, GitResetMode, GitSignatureStatus, GitStash, MergeActionOn, PipelineConfig, PipelineProvider, RebaseActionOn, SquashMessageFormat, TagType, Writeable } from './types';
import { CIDIConfig, CIDIProvider, CommitOrdering, DateType, DeepWriteable, ErrorInfo, GitCIDIData, GitCommit, GitCommitDetails, GitCommitStash, GitConfigLocation, GitFileChange, GitFileStatus, GitPushBranchMode, GitRepoConfig, GitRepoConfigBranches, GitResetMode, GitSignatureStatus, GitStash, MergeActionOn, RebaseActionOn, SquashMessageFormat, TagType, Writeable } from './types';
import { GitExecutable, UNABLE_TO_FIND_GIT_MSG, UNCOMMITTED, abbrevCommit, constructIncompatibleGitVersionMessage, getPathFromStr, getPathFromUri, isGitAtLeastVersion, openGitTerminal, pathWithTrailingSlash, realpath, resolveSpawnOutput, showErrorMessage } from './utils';
import { Disposable } from './utils/disposable';
import { Event } from './utils/event';
Expand Down Expand Up @@ -159,15 +159,15 @@ export class DataSource extends Disposable {
* @param stashes An array of all stashes in the repository.
* @returns The commits in the repository.
*/
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>, pipelineConfigs: PipelineConfig[] | null): Promise<GitCommitData> {
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>, cidiConfigs: CIDIConfig[] | null): Promise<GitCommitData> {
const config = getConfig();
return Promise.all([
this.getLog(repo, branches, maxCommits + 1, showTags && config.showCommitsOnlyReferencedByTags, showRemoteBranches, includeCommitsMentionedByReflogs, onlyFollowFirstParent, commitOrdering, remotes, hideRemotes, stashes),
this.getRefs(repo, showRemoteBranches, config.showRemoteHeads, hideRemotes).then((refData: GitRefData) => refData, (errorMessage: string) => errorMessage),
this.getPipelines(pipelineConfigs).then((refData: GitPipelinesData[] | string | undefined) => refData, (errorMessage: string) => errorMessage)
this.getCIDIs(cidiConfigs).then((refData: GitCIDIData[] | string | undefined) => refData, (errorMessage: string) => errorMessage)
]).then(async (results) => {
let commits: GitCommitRecord[] = results[0], refData: GitRefData | string = results[1], i;
let pipelines: GitPipelinesData[] | string | undefined = results[2];
let cidis: GitCIDIData[] | string | undefined = results[2];
let moreCommitsAvailable = commits.length === maxCommits + 1;
if (moreCommitsAvailable) commits.pop();

Expand Down Expand Up @@ -200,7 +200,7 @@ export class DataSource extends Disposable {

for (i = 0; i < commits.length; i++) {
commitLookup[commits[i].hash] = i;
commitNodes.push({ ...commits[i], heads: [], tags: [], remotes: [], stash: null, pipeline: null });
commitNodes.push({ ...commits[i], heads: [], tags: [], remotes: [], stash: null, cidi: null });
}

/* Insert Stashes */
Expand All @@ -220,7 +220,7 @@ export class DataSource extends Disposable {
for (i = toAdd.length - 1; i >= 0; i--) {
let stash = toAdd[i].data;
commitNodes.splice(toAdd[i].index, 0, {
pipeline: null,
cidi: null,
hash: stash.hash,
parents: [stash.baseHash],
author: stash.author,
Expand Down Expand Up @@ -261,13 +261,13 @@ export class DataSource extends Disposable {
}
}

if (typeof pipelines === 'string' || typeof pipelines === 'undefined') {
pipelines = [];
if (typeof cidis === 'string' || typeof cidis === 'undefined') {
cidis = [];
}
/* Annotate Pipelines */
for (i = 0; i < pipelines.length; i++) {
if (typeof commitLookup[pipelines[i].sha] === 'number') {
commitNodes[commitLookup[pipelines[i].sha]].pipeline = pipelines[i];
/* Annotate CI/DIs */
for (i = 0; i < cidis.length; i++) {
if (typeof commitLookup[cidis[i].sha] === 'number') {
commitNodes[commitLookup[cidis[i].sha]].cidi = cidis[i];
}
}

Expand Down Expand Up @@ -1512,33 +1512,33 @@ export class DataSource extends Disposable {
}

/**
* Get the result in a Pipelines.
* @param pipelineConfigs pipeline configuration.
* Get the result in a CI/DIs.
* @param cidiConfigs CI/DI configuration.
* @returns The references data.
*/
private async getPipelines(pipelineConfigs: PipelineConfig[] | null) {
if (pipelineConfigs === null) {
private async getCIDIs(cidiConfigs: CIDIConfig[] | null) {
if (cidiConfigs === null) {
return '';
}

return await Promise.all(
pipelineConfigs.map(async pipelineConfig => {
if (pipelineConfig.provider === PipelineProvider.GitHubV3) {
cidiConfigs.map(async cidiConfig => {
if (cidiConfig.provider === CIDIProvider.GitHubV3) {

const match1 = pipelineConfig.gitUrl.match(/^(https?:\/\/|git@)((?=[^/]+@)[^@]+@|(?![^/]+@))([^/:]+)/);
const match1 = cidiConfig.gitUrl.match(/^(https?:\/\/|git@)((?=[^/]+@)[^@]+@|(?![^/]+@))([^/:]+)/);
let hostRootUrl = match1 !== null ? 'https://api.' + match1[3] : '';

const match2 = pipelineConfig.gitUrl.match(/^(https?:\/\/|git@)[^/:]+[/:]([^/]+)\/([^/]*?)(.git|)$/);
const match2 = cidiConfig.gitUrl.match(/^(https?:\/\/|git@)[^/:]+[/:]([^/]+)\/([^/]*?)(.git|)$/);
let sourceOwner = match2 !== null ? match2[2] : '';
let sourceRepo = match2 !== null ? match2[3] : '';

const apiRoot = `${hostRootUrl}`;
const pipelinesRootPath = `/repos/${sourceOwner}/${sourceRepo.replace(/\//g, '%2F')}/actions/runs?per_page=100`;
const cidiRootPath = `/repos/${sourceOwner}/${sourceRepo.replace(/\//g, '%2F')}/actions/runs?per_page=100`;

const config: request.RequestPromiseOptions = {
method: 'GET',
headers: {
'Authorization': `token ${pipelineConfig.glToken}`,
'Authorization': `token ${cidiConfig.glToken}`,
'Accept': 'application/vnd.github.v3+json',
'User-Agent': 'vscode-git-graph'
}
Expand Down Expand Up @@ -1585,7 +1585,7 @@ export class DataSource extends Disposable {
});
}
if (typeof res['workflow_runs'] !== 'undefined' && res['workflow_runs'].length >= 1) { // url found
let ret: GitPipelinesData[] = res['workflow_runs'].map( (elm: { [x: string]: any; }) => {
let ret: GitCIDIData[] = res['workflow_runs'].map( (elm: { [x: string]: any; }) => {
return {
id: elm['id'],
status: elm['conclusion'],
Expand All @@ -1606,37 +1606,37 @@ export class DataSource extends Disposable {
return { x_total_pages: 0, ret: e };
}
};
return request(`${apiRoot}${pipelinesRootPath}`, config).then(async (result1st) => {
return request(`${apiRoot}${cidiRootPath}`, config).then(async (result1st) => {
let promises = [];
promises.push(result1st.ret);
for (let i = 1; i < result1st.x_total_pages; i++) {
promises.push(request(`${apiRoot}${pipelinesRootPath}&page=${i + 1}`, config));
promises.push(request(`${apiRoot}${cidiRootPath}&page=${i + 1}`, config));
}
return await Promise.all(promises);
}).then((resultAll) => {
let retAll: GitPipelinesData[] = [];
let retAll: GitCIDIData[] = [];
for (let i = 0; i < resultAll.length; i++) {
retAll = retAll.concat(resultAll[i]);
}
return retAll;
});
}
if (pipelineConfig.provider === PipelineProvider.GitLabV4) {
if (cidiConfig.provider === CIDIProvider.GitLabV4) {

const match1 = pipelineConfig.gitUrl.match(/^(https?:\/\/|git@)((?=[^/]+@)[^@]+@|(?![^/]+@))([^/:]+)/);
const match1 = cidiConfig.gitUrl.match(/^(https?:\/\/|git@)((?=[^/]+@)[^@]+@|(?![^/]+@))([^/:]+)/);
let hostRootUrl = match1 !== null ? 'https://' + match1[3] : '';

const match2 = pipelineConfig.gitUrl.match(/^(https?:\/\/|git@)[^/:]+[/:]([^/]+)\/([^/]*?)(.git|)$/);
const match2 = cidiConfig.gitUrl.match(/^(https?:\/\/|git@)[^/:]+[/:]([^/]+)\/([^/]*?)(.git|)$/);
let sourceOwner = match2 !== null ? match2[2] : '';
let sourceRepo = match2 !== null ? match2[3] : '';

const apiRoot = `${hostRootUrl}/api/v4`;
const pipelinesRootPath = `/projects/${sourceOwner}%2F${sourceRepo.replace(/\//g, '%2F')}/pipelines?per_page=100`;
const cidiRootPath = `/projects/${sourceOwner}%2F${sourceRepo.replace(/\//g, '%2F')}/pipelines?per_page=100`;

const config: request.RequestPromiseOptions = {
method: 'GET',
headers: {
'PRIVATE-TOKEN': pipelineConfig.glToken,
'PRIVATE-TOKEN': cidiConfig.glToken,
'User-Agent': 'vscode-git-graph'
}
};
Expand All @@ -1646,7 +1646,7 @@ export class DataSource extends Disposable {
if (typeof response.headers['x-page'] === 'string' && typeof response.headers['x-total-pages'] === 'string' && typeof response.headers['x-total'] === 'string') {
let res: any = JSON.parse(body);
if (parseInt(response.headers['x-total']) !== 0 && res.length && res[0].id) { // url found
let ret: GitPipelinesData[] = res;
let ret: GitCIDIData[] = res;
if (parseInt(response.headers['x-page']) === 1) {
return { x_total_pages: parseInt(response.headers['x-total-pages']), ret: ret };
}
Expand All @@ -1658,15 +1658,15 @@ export class DataSource extends Disposable {
return { x_total_pages: 0, ret: e };
}
};
return request(`${apiRoot}${pipelinesRootPath}`, config).then(async (result1st) => {
return request(`${apiRoot}${cidiRootPath}`, config).then(async (result1st) => {
let promises = [];
promises.push(result1st.ret);
for (let i = 1; i < result1st.x_total_pages; i++) {
promises.push(request(`${apiRoot}${pipelinesRootPath}&page=${i + 1}`, config));
promises.push(request(`${apiRoot}${cidiRootPath}&page=${i + 1}`, config));
}
return await Promise.all(promises);
}).then((resultAll) => {
let retAll: GitPipelinesData[] = [];
let retAll: GitCIDIData[] = [];
for (let i = 0; i < resultAll.length; i++) {
retAll = retAll.concat(resultAll[i]);
}
Expand All @@ -1675,7 +1675,7 @@ export class DataSource extends Disposable {
}
})
).then((resultAll2) => {
let retAll: GitPipelinesData[] = [];
let retAll: GitCIDIData[] = [];
resultAll2.forEach(resultList => {
resultList?.forEach(result => {
retAll = retAll.concat(result);
Expand Down
2 changes: 1 addition & 1 deletion src/extensionState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const DEFAULT_REPO_STATE: GitRepoState = {
onRepoLoadShowCheckedOutBranch: BooleanOverride.Default,
onRepoLoadShowSpecificBranches: null,
pullRequestConfig: null,
pipelineConfigs: null,
cidiConfigs: null,
showRemoteBranches: true,
showRemoteBranchesV2: BooleanOverride.Default,
showStashes: BooleanOverride.Default,
Expand Down
2 changes: 1 addition & 1 deletion src/gitGraphView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ export class GitGraphView extends Disposable {
command: 'loadCommits',
refreshId: msg.refreshId,
onlyFollowFirstParent: msg.onlyFollowFirstParent,
...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, msg.pipelineConfigs)
...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, msg.cidiConfigs)
});
break;
case 'loadConfig':
Expand Down
24 changes: 12 additions & 12 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* Git Interfaces / Types */

export interface GitCommit {
readonly pipeline: GitPipelinesData | null;
readonly hash: string;
readonly parents: ReadonlyArray<string>;
readonly author: string;
Expand All @@ -12,9 +11,10 @@ export interface GitCommit {
readonly tags: ReadonlyArray<GitCommitTag>;
readonly remotes: ReadonlyArray<GitCommitRemote>;
readonly stash: GitCommitStash | null; // null => not a stash, otherwise => stash info
readonly cidi: GitCIDIData | null;
}

export interface GitPipelinesData {
export interface GitCIDIData {
id: string;
status: string;
ref: string;
Expand Down Expand Up @@ -201,33 +201,33 @@ export type PullRequestConfig = PullRequestConfigBuiltIn | PullRequestConfigCust



export interface PipelineConfigBase {
export interface CIDIConfigBase {
readonly gitUrl: string;
readonly glToken: string;
}

export const enum PipelineProvider {
export const enum CIDIProvider {
Bitbucket,
Custom,
GitHubV3,
GitLabV4,
Jenkins
}

interface PipelineConfigBuiltIn extends PipelineConfigBase {
readonly provider: PipelineProvider;
interface CIDIConfigBuiltIn extends CIDIConfigBase {
readonly provider: CIDIProvider;
readonly custom: null;
}

interface PipelineConfigCustom extends PipelineConfigBase {
readonly provider: PipelineProvider.Custom;
interface CIDIConfigCustom extends CIDIConfigBase {
readonly provider: CIDIProvider.Custom;
readonly custom: {
readonly name: string,
readonly templateUrl: string
};
}

export type PipelineConfig = PipelineConfigBuiltIn | PipelineConfigCustom;
export type CIDIConfig = CIDIConfigBuiltIn | CIDIConfigCustom;

export interface GitRepoState {
cdvDivider: number;
Expand All @@ -244,7 +244,7 @@ export interface GitRepoState {
onRepoLoadShowCheckedOutBranch: BooleanOverride;
onRepoLoadShowSpecificBranches: string[] | null;
pullRequestConfig: PullRequestConfig | null;
pipelineConfigs: PipelineConfig[] | null;
cidiConfigs: CIDIConfig[] | null;
showRemoteBranches: boolean;
showRemoteBranchesV2: BooleanOverride;
showStashes: BooleanOverride;
Expand Down Expand Up @@ -469,7 +469,7 @@ export interface DefaultColumnVisibility {
readonly date: boolean;
readonly author: boolean;
readonly commit: boolean;
readonly pipeline: boolean;
readonly cidi: boolean;
}

export interface DialogDefaults {
Expand Down Expand Up @@ -927,7 +927,7 @@ export interface RequestLoadCommits extends RepoRequest {
readonly remotes: ReadonlyArray<string>;
readonly hideRemotes: ReadonlyArray<string>;
readonly stashes: ReadonlyArray<GitStash>;
readonly pipelineConfigs: PipelineConfig[] | null;
readonly cidiConfigs: CIDIConfig[] | null;
}
export interface ResponseLoadCommits extends ResponseWithErrorInfo {
readonly command: 'loadCommits';
Expand Down
Loading

0 comments on commit c97c255

Please sign in to comment.