Browse Source

Pipe downstream info through to graph (#2552)

* Pipe downstream info through to graph

* Optimizations

* Updates graph dependency
main
Ramin Tadayon 1 year ago
committed by GitHub
parent
commit
f14af9dc4a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 54 additions and 12 deletions
  1. +1
    -1
      package.json
  2. +15
    -0
      src/env/node/git/localGitProvider.ts
  3. +1
    -0
      src/git/models/graph.ts
  4. +15
    -0
      src/plus/github/githubGitProvider.ts
  5. +4
    -4
      src/plus/webviews/graph/graphWebview.ts
  6. +3
    -0
      src/plus/webviews/graph/protocol.ts
  7. +10
    -3
      src/webviews/apps/plus/graph/GraphWrapper.tsx
  8. +1
    -0
      src/webviews/apps/plus/graph/graph.tsx
  9. +4
    -4
      yarn.lock

+ 1
- 1
package.json View File

@ -13361,7 +13361,7 @@
"vscode:prepublish": "yarn run bundle"
},
"dependencies": {
"@gitkraken/gitkraken-components": "7.0.0",
"@gitkraken/gitkraken-components": "7.1.0",
"@microsoft/fast-element": "1.11.0",
"@microsoft/fast-react-wrapper": "0.3.16-0",
"@octokit/core": "4.2.0",

+ 15
- 0
src/env/node/git/localGitProvider.ts View File

@ -1733,6 +1733,8 @@ export class LocalGitProvider implements GitProvider, Disposable {
const remoteMap = remotes != null ? new Map(remotes.map(r => [r.name, r])) : new Map<string, GitRemote>();
const selectSha = first(refParser.parse(getSettledValue(refResult) ?? ''));
const downstreamMap = new Map<string, string[]>();
let stdin: string | undefined;
// TODO@eamodio this is insanity -- there *HAS* to be a better way to get git log to return stashes
const stash = getSettledValue(stashResult);
@ -1795,6 +1797,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
includes: options?.include,
branches: branchMap,
remotes: remoteMap,
downstreams: downstreamMap,
rows: [],
};
}
@ -1816,6 +1819,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
includes: options?.include,
branches: branchMap,
remotes: remoteMap,
downstreams: downstreamMap,
rows: [],
};
}
@ -2001,6 +2005,16 @@ export class LocalGitProvider implements GitProvider, Disposable {
upstream: branch?.upstream?.name,
};
refHeads.push(refHead);
if (branch?.upstream?.name != null) {
// Add the branch name (tip) to the upstream name entry in the downstreams map
let downstreams = downstreamMap.get(branch.upstream.name);
if (downstreams == null) {
downstreams = [];
downstreamMap.set(branch.upstream.name, downstreams);
}
downstreams.push(tip);
}
group = groupedRefs.get(tip);
if (group == null) {
@ -2138,6 +2152,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
skippedIds: skippedIds,
branches: branchMap,
remotes: remoteMap,
downstreams: downstreamMap,
rows: rows,
id: sha,

+ 1
- 0
src/git/models/graph.ts View File

@ -36,6 +36,7 @@ export interface GitGraph {
readonly skippedIds?: Set<string>;
readonly branches: Map<string, GitBranch>;
readonly remotes: Map<string, GitRemote>;
readonly downstreams: Map<string, string[]>;
/** The rows for the set of commits requested */
readonly rows: GitGraphRow[];
readonly id?: string;

+ 15
- 0
src/plus/github/githubGitProvider.ts View File

@ -1157,6 +1157,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
const includes = { ...options?.include, stats: true }; // stats are always available, so force it
const branchMap = branch != null ? new Map([[branch.name, branch]]) : new Map<string, GitBranch>();
const remoteMap = remote != null ? new Map([[remote.name, remote]]) : new Map<string, GitRemote>();
const downstreamMap = new Map<string, string[]>();
if (log == null) {
return {
repoPath: repoPath,
@ -1165,6 +1166,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
includes: includes,
branches: branchMap,
remotes: remoteMap,
downstreams: downstreamMap,
rows: [],
};
}
@ -1178,6 +1180,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
includes: includes,
branches: branchMap,
remotes: remoteMap,
downstreams: downstreamMap,
rows: [],
};
}
@ -1246,6 +1249,17 @@ export class GitHubGitProvider implements GitProvider, Disposable {
current: true,
},
];
if (branch.upstream?.name != null) {
// Add the branch name (tip) to the upstream name entry in the downstreams map
let downstreams = downstreamMap.get(branch.upstream.name);
if (downstreams == null) {
downstreams = [];
downstreamMap.set(branch.upstream.name, downstreams);
}
downstreams.push(branch.name);
}
} else {
refHeads = [];
refRemoteHeads = [];
@ -1348,6 +1362,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
includes: includes,
branches: branchMap,
remotes: remoteMap,
downstreams: downstreamMap,
rows: rows,
id: options?.ref,

+ 4
- 4
src/plus/webviews/graph/graphWebview.ts View File

@ -1290,6 +1290,7 @@ export class GraphWebview extends WebviewBase {
DidChangeRowsNotificationType,
{
rows: data.rows,
downstreams: Object.fromEntries(data.downstreams),
avatars: Object.fromEntries(data.avatars),
refsMetadata: this._refsMetadata != null ? Object.fromEntries(this._refsMetadata) : this._refsMetadata,
selectedRows: sendSelectedRows ? this._selectedRows : undefined,
@ -1590,8 +1591,6 @@ export class GraphWebview extends WebviewBase {
const storedIncludeOnlyRefs = storedFilters?.includeOnlyRefs;
if (storedIncludeOnlyRefs == null || Object.keys(storedIncludeOnlyRefs).length === 0) return undefined;
const includeRemotes = !(storedFilters?.excludeTypes?.remotes ?? false);
const includeOnlyRefs: Record<string, StoredGraphIncludeOnlyRef> = {};
for (const [key, value] of Object.entries(storedIncludeOnlyRefs)) {
@ -1605,8 +1604,8 @@ export class GraphWebview extends WebviewBase {
includeOnlyRefs[key] = value;
}
// Add the upstream branches for any local branches if there are any and we aren't excluding them
if (includeRemotes && value.type === 'head') {
// Add the upstream branches for any local branches if there are any
if (value.type === 'head') {
branch = branch ?? graph.branches.get(value.name);
if (branch?.upstream != null && !branch.upstream.missing) {
const id = getBranchId(graph.repoPath, true, branch.upstream.name);
@ -1856,6 +1855,7 @@ export class GraphWebview extends WebviewBase {
refsMetadata: this.resetRefsMetadata() === null ? null : {},
loading: deferRows,
rows: data?.rows,
downstreams: data != null ? Object.fromEntries(data.downstreams) : undefined,
paging:
data != null
? {

+ 3
- 0
src/plus/webviews/graph/protocol.ts View File

@ -33,6 +33,7 @@ export type { GraphRefType } from '@gitkraken/gitkraken-components';
export type GraphColumnsSettings = Record<GraphColumnName, GraphColumnSetting>;
export type GraphSelectedRows = Record</*id*/ string, true>;
export type GraphAvatars = Record</*email*/ string, /*url*/ string>;
export type GraphDownstreams = Record</*upstreamName*/ string, /*downstreamNames*/ string[]>;
export type GraphRefMetadata = RefMetadata | null;
export type GraphUpstreamMetadata = UpstreamMetadata | null;
@ -87,6 +88,7 @@ export interface State {
loading?: boolean;
refsMetadata?: GraphRefsMetadata | null;
rows?: GraphRow[];
downstreams?: GraphDownstreams;
paging?: GraphPaging;
columns?: GraphColumnsSettings;
config?: GraphComponentConfig;
@ -354,6 +356,7 @@ export const DidChangeRefsVisibilityNotificationType = new IpcNotificationType
export interface DidChangeRowsParams {
rows: GraphRow[];
downstreams: { [upstreamName: string]: string[] };
avatars: { [email: string]: string };
paging?: GraphPaging;
refsMetadata?: GraphRefsMetadata | null;

+ 10
- 3
src/webviews/apps/plus/graph/GraphWrapper.tsx View File

@ -186,6 +186,7 @@ export function GraphWrapper({
const [rows, setRows] = useState(state.rows ?? []);
const [avatars, setAvatars] = useState(state.avatars);
const [downstreams, setDownstreams] = useState(state.downstreams ?? {});
const [refsMetadata, setRefsMetadata] = useState(state.refsMetadata);
const [repos, setRepos] = useState(state.repositories ?? []);
const [repo, setRepo] = useState<GraphRepository | undefined>(
@ -266,6 +267,7 @@ export function GraphWrapper({
setRows(state.rows ?? []);
setSelectedRows(state.selectedRows);
setAvatars(state.avatars);
setDownstreams(state.downstreams ?? {});
setRefsMetadata(state.refsMetadata);
setPagingHasMore(state.paging?.hasMore ?? false);
setIsLoading(state.loading);
@ -316,6 +318,7 @@ export function GraphWrapper({
setIncludeOnlyRefsById(state.includeOnlyRefs);
setContext(state.context);
setAvatars(state.avatars ?? {});
setDownstreams(state.downstreams ?? {});
setRefsMetadata(state.refsMetadata);
setPagingHasMore(state.paging?.hasMore ?? false);
setRepos(state.repositories ?? []);
@ -447,7 +450,8 @@ export function GraphWrapper({
if (
row.remotes?.length &&
(enabledMinimapMarkers.includes(GraphMinimapMarkerTypes.Upstream) ||
enabledMinimapMarkers.includes(GraphMinimapMarkerTypes.RemoteBranches))
enabledMinimapMarkers.includes(GraphMinimapMarkerTypes.RemoteBranches) ||
enabledMinimapMarkers.includes(GraphMinimapMarkerTypes.LocalBranches))
) {
rankedShas.remote = row.sha;
@ -456,6 +460,7 @@ export function GraphWrapper({
// eslint-disable-next-line no-loop-func
row.remotes.forEach(r => {
let current = false;
const hasDownstream = downstreams?.[`${r.owner}/${r.name}`]?.length;
if (r.current) {
rankedShas.remote = row.sha;
current = true;
@ -463,7 +468,8 @@ export function GraphWrapper({
if (
enabledMinimapMarkers.includes(GraphMinimapMarkerTypes.RemoteBranches) ||
(enabledMinimapMarkers.includes(GraphMinimapMarkerTypes.Upstream) && current)
(enabledMinimapMarkers.includes(GraphMinimapMarkerTypes.Upstream) && current) ||
(enabledMinimapMarkers.includes(GraphMinimapMarkerTypes.LocalBranches) && hasDownstream)
) {
remoteMarkers.push({
type: 'remote',
@ -538,7 +544,7 @@ export function GraphWrapper({
}
return { stats: statsByDayMap, markers: markersByDay };
}, [rows, graphConfig?.minimap, graphConfig?.enabledMinimapMarkerTypes]);
}, [rows, downstreams, graphConfig?.minimap, graphConfig?.enabledMinimapMarkerTypes]);
const minimapSearchResults = useMemo(() => {
if (
@ -1301,6 +1307,7 @@ export function GraphWrapper({
contexts={context}
cssVariables={styleProps?.cssVariables}
dimMergeCommits={graphConfig?.dimMergeCommits}
downstreamsByUpstream={downstreams}
enabledRefMetadataTypes={graphConfig?.enabledRefMetadataTypes}
enabledScrollMarkerTypes={
graphConfig?.enabledScrollMarkerTypes as GraphMarkerType[] | undefined

+ 1
- 0
src/webviews/apps/plus/graph/graph.tsx View File

@ -266,6 +266,7 @@ export class GraphApp extends App {
}
this.state.avatars = params.avatars;
this.state.downstreams = params.downstreams;
if (params.refsMetadata !== undefined) {
this.state.refsMetadata = params.refsMetadata;
}

+ 4
- 4
yarn.lock View File

@ -190,10 +190,10 @@
resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.3.tgz#555193ab2e3bb3b6adc3d551c9c030d9e860daf6"
integrity sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw==
"@gitkraken/gitkraken-components@7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@gitkraken/gitkraken-components/-/gitkraken-components-7.0.0.tgz#af908e3e5144a6c45c8827463de8887b08847b47"
integrity sha512-Cc6qaYBS56+kGopyw3G3aJdcsdFB2LvAG44Ijo3ETEUjS/P8UN/g6nluFLenzlh9Of6v86HZ92jhjldDHb5OUQ==
"@gitkraken/gitkraken-components@7.1.0":
version "7.1.0"
resolved "https://registry.yarnpkg.com/@gitkraken/gitkraken-components/-/gitkraken-components-7.1.0.tgz#5423220c943f0f4406f61a23362ba0fc97b99e05"
integrity sha512-Qu8mETfyzLRUNxYAWfqYoxNV14gYvS8N8Jvvlz39tnzjlj13CBcfaj7VOC7N3vxSqzBNpy+/Qht/dtrtcMWMUA==
dependencies:
"@axosoft/react-virtualized" "9.22.3-gitkraken.3"
classnames "2.3.2"

Loading…
Cancel
Save