Skip to content

Commit

Permalink
Merge pull request #59 from davelopez/disable_timeline_diff
Browse files Browse the repository at this point in the history
Disable clean diff comparisons in Timeline (temporarily)
  • Loading branch information
davelopez authored Sep 24, 2023
2 parents 6d0ad7b + 19417bf commit d7cf1bc
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 20 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ You can clean up the non-essential properties of a (legacy .ga) workflow with th

> ⚠️ This feature is experimental and is only available using a local git repository.
Sometimes you want to compare different revisions of the same (legacy .ga) workflow and see what has changed between them. If the workflow has been through the Galaxy editor or some of the nodes have been moved around, there can be many changes that are just cosmetical and not part of the workflow logic. In those cases, you may want to get a 'simplified' diff so you can focus on the 'real' changes. You can do so in the `Timeline` or the `File Explorer` by using `Select workflow for (clean) compare` in one revision and then `Compare with this workflow (clean)` on the other revision, this will compare both revisions using the 'clean' version of the workflow (see the [Workflow Cleanup Command](#workflow-cleanup-command)), meaning the non-essential parts are removed from both documents before the comparison.
Sometimes you want to compare different revisions of the same (legacy .ga) workflow and see what has changed between them. If the workflow has been through the Galaxy editor or some of the nodes have been moved around, there can be many changes that are just cosmetical and not part of the workflow logic. In those cases, you may want to get a 'simplified' diff so you can focus on the 'real' changes. You can do so in <del>the `Timeline` or</del> the `File Explorer` by using `Select workflow for (clean) compare` in one revision and then `Compare with this workflow (clean)` on the other revision, this will compare both revisions using the 'clean' version of the workflow (see the [Workflow Cleanup Command](#workflow-cleanup-command)), meaning the non-essential parts are removed from both documents before the comparison.

> ⚠️ **NOTE**:
> This feature is no longer supported in the `Timeline` until a new version of the VSCode Timeline API is finalized and published. See [this PR](https://github.com/davelopez/galaxy-workflows-vscode/pull/59) for more details.
#### Legacy (ga)

Expand Down
65 changes: 57 additions & 8 deletions client/src/@types/git.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { Uri, Event, Disposable, ProviderResult } from "vscode";
import { Uri, Event, Disposable, ProviderResult, Command, CancellationToken } from "vscode";
export { ProviderResult } from "vscode";

export interface Git {
Expand Down Expand Up @@ -78,6 +78,8 @@ export const enum Status {
UNTRACKED,
IGNORED,
INTENT_TO_ADD,
INTENT_TO_RENAME,
TYPE_CHANGED,

ADDED_BY_US,
ADDED_BY_THEM,
Expand Down Expand Up @@ -126,6 +128,8 @@ export interface LogOptions {
/** Max number of log entries to retrieve. If not specified, the default is 32. */
readonly maxEntries?: number;
readonly path?: string;
/** A commit range, such as "0a47c67f0fb52dd11562af48658bc1dff1d75a38..0bb4bdea78e1db44d728fd6894720071e303304f" */
readonly range?: string;
}

export interface CommitOptions {
Expand All @@ -136,6 +140,15 @@ export interface CommitOptions {
empty?: boolean;
noVerify?: boolean;
requireUserConfig?: boolean;
useEditor?: boolean;
verbose?: boolean;
/**
* string - execute the specified command after the commit operation
* undefined - execute the command specified in git.postCommitCommand
* after the commit operation
* null - do not execute any command after the commit operation
*/
postCommitCommand?: string | null;
}

export interface FetchOptions {
Expand All @@ -146,11 +159,19 @@ export interface FetchOptions {
depth?: number;
}

export interface BranchQuery {
readonly remote?: boolean;
readonly pattern?: string;
readonly count?: number;
export interface InitOptions {
defaultBranch?: string;
}

export interface RefQuery {
readonly contains?: string;
readonly count?: number;
readonly pattern?: string;
readonly sort?: "alphabetically" | "committerdate";
}

export interface BranchQuery extends RefQuery {
readonly remote?: boolean;
}

export interface Repository {
Expand All @@ -171,6 +192,7 @@ export interface Repository {
getCommit(ref: string): Promise<Commit>;

add(paths: string[]): Promise<void>;
revert(paths: string[]): Promise<void>;
clean(paths: string[]): Promise<void>;

apply(patch: string, reverse?: boolean): Promise<void>;
Expand All @@ -192,9 +214,11 @@ export interface Repository {
createBranch(name: string, checkout: boolean, ref?: string): Promise<void>;
deleteBranch(name: string, force?: boolean): Promise<void>;
getBranch(name: string): Promise<Branch>;
getBranches(query: BranchQuery): Promise<Ref[]>;
getBranches(query: BranchQuery, cancellationToken?: CancellationToken): Promise<Ref[]>;
setBranchUpstream(name: string, upstream: string): Promise<void>;

getRefs(query: RefQuery, cancellationToken?: CancellationToken): Promise<Ref[]>;

getMergeBase(ref1: string, ref2: string): Promise<string>;

tag(name: string, upstream: string): Promise<void>;
Expand Down Expand Up @@ -248,6 +272,10 @@ export interface CredentialsProvider {
getCredentials(host: Uri): ProviderResult<Credentials>;
}

export interface PostCommitCommandsProvider {
getCommands(repository: Repository): Command[];
}

export interface PushErrorHandler {
handlePushError(
repository: Repository,
Expand All @@ -257,6 +285,21 @@ export interface PushErrorHandler {
): Promise<boolean>;
}

export interface BranchProtection {
readonly remote: string;
readonly rules: BranchProtectionRule[];
}

export interface BranchProtectionRule {
readonly include?: string[];
readonly exclude?: string[];
}

export interface BranchProtectionProvider {
onDidChangeBranchProtection: Event<Uri>;
provideBranchProtection(): BranchProtection[];
}

export type APIState = "uninitialized" | "initialized";

export interface PublishEvent {
Expand All @@ -275,13 +318,15 @@ export interface API {

toGitUri(uri: Uri, ref: string): Uri;
getRepository(uri: Uri): Repository | null;
init(root: Uri): Promise<Repository | null>;
init(root: Uri, options?: InitOptions): Promise<Repository | null>;
openRepository(root: Uri): Promise<Repository | null>;

registerRemoteSourcePublisher(publisher: RemoteSourcePublisher): Disposable;
registerRemoteSourceProvider(provider: RemoteSourceProvider): Disposable;
registerCredentialsProvider(provider: CredentialsProvider): Disposable;
registerPostCommitCommandsProvider(provider: PostCommitCommandsProvider): Disposable;
registerPushErrorHandler(handler: PushErrorHandler): Disposable;
registerBranchProtectionProvider(root: Uri, provider: BranchProtectionProvider): Disposable;
}

export interface GitExtension {
Expand All @@ -291,7 +336,7 @@ export interface GitExtension {
/**
* Returns a specific API version.
*
* Throws error if git extension is disabled. You can listed to the
* Throws error if git extension is disabled. You can listen to the
* [GitExtension.onDidChangeEnablement](#GitExtension.onDidChangeEnablement) event
* to know when the extension becomes enabled/disabled.
*
Expand Down Expand Up @@ -337,4 +382,8 @@ export const enum GitErrorCodes {
PatchDoesNotApply = "PatchDoesNotApply",
NoPathFound = "NoPathFound",
UnknownPath = "UnknownPath",
EmptyCommitMessage = "EmptyCommitMessage",
BranchFastForwardRejected = "BranchFastForwardRejected",
BranchNotYetBorn = "BranchNotYetBorn",
TagConflict = "TagConflict",
}
2 changes: 1 addition & 1 deletion client/src/commands/compareCleanWith.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class CompareCleanWithWorkflowsCommand extends CustomCommand {
const rightComparable = ComparableWorkflow.buildFromArgs(args);

if (!leftComparable || !rightComparable) {
throw new Error("You need to two workflows selected for comparison");
throw new Error("You need to have two workflows selected for comparison");
}

const leftUri = this.buildCleanWorkflowUri(leftComparable);
Expand Down
17 changes: 11 additions & 6 deletions client/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,21 @@ export abstract class CustomCommand extends CommandContext {
*/
export class ComparableWorkflow {
uri: Uri;
ref: string;
ref?: string;

// TODO: This is no longer working until a new API is available
// ref: https://github.com/microsoft/vscode/issues/177319
// ref: https://github.com/microsoft/vscode/issues/84297
public static buildFromArgs(args: unknown[]): ComparableWorkflow | undefined {
if (args.length >= 2) {
if (Object.prototype.hasOwnProperty.call(args[0], "ref")) {
const source = args[2] as string;
if (source === "git-history") {
// Comes from source control timeline
return { uri: args[1] as Uri, ref: args[0]["ref"] };
} else if (Object.prototype.hasOwnProperty.call(args[0], "scheme")) {
// Comes from file explorer
return { uri: args[0] as Uri, ref: undefined };
return { uri: args[1] as Uri, ref: args[0] as string };
}
if (source === "timeline.localHistory") {
// Comes from local history
return { uri: args[1] as Uri };
}
}
return undefined;
Expand Down
10 changes: 8 additions & 2 deletions client/src/providers/git/gitProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { GitProvider } from ".";
* This providers can be used only with local git repositories.
*/
export class BuiltinGitProvider implements GitProvider {
private gitAPI: GitAPI = undefined;
private gitAPI?: GitAPI = undefined;

async initialize(): Promise<void> {
this.gitAPI = await this.getBuiltInGitApi();
Expand All @@ -18,14 +18,20 @@ export class BuiltinGitProvider implements GitProvider {
}

async getContents(uri: Uri, ref: string): Promise<string> {
if (this.gitAPI === undefined) {
throw new Error("Git provider not initialized");
}
const gitUri = this.gitAPI.toGitUri(uri, ref);
const repo = this.gitAPI.getRepository(gitUri);
if (repo === null) {
throw new Error(`Repository not found for uri ${uri.toString()}`);
}
const contents = await repo.show(ref, uri.path);

return contents;
}

private async getBuiltInGitApi(): Promise<GitAPI> {
private async getBuiltInGitApi(): Promise<GitAPI | undefined> {
try {
const extension = extensions.getExtension("vscode.git") as Extension<GitExtension>;
if (extension !== undefined) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@
{
"command": "galaxy-workflows.compareCleanWith",
"group": "3_compare@1",
"when": "config.git.enabled && !git.missing && galaxy-workflows.selectForCleanCompare"
"when": "false && config.git.enabled && !git.missing && galaxy-workflows.selectForCleanCompare"
},
{
"command": "galaxy-workflows.selectForCleanCompare",
"group": "3_compare@2",
"when": "config.git.enabled && !git.missing && timelineItem =~ /git:file\\b/ && galaxy-workflows.gitProviderInitialized"
"when": "false && config.git.enabled && !git.missing && timelineItem =~ /git:file\\b/ && galaxy-workflows.gitProviderInitialized"
}
],
"explorer/context": [
Expand Down

0 comments on commit d7cf1bc

Please sign in to comment.