Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

libzap

Package Overview
Dependencies
Maintainers
8
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libzap - npm Package Compare versions

Comparing version 0.0.98 to 0.0.99

lib/ref.d.ts

7

lib/remote/handler.d.ts

@@ -5,3 +5,3 @@ import { Event } from "vscode-jsonrpc";

import { IConnection } from "./connection";
import { RefIdentifier, RefInfo, WorkspaceWillSaveFileParams } from "./protocol";
import { RefIdentifier, RefInfo, RefUpdateDownstreamParams, WorkspaceWillSaveFileParams } from "./protocol";
export declare enum MergeStrategy {

@@ -25,3 +25,3 @@ LocalClobbersRemote = 1,

export interface SymbolicRefUpdateEvent extends RefIdentifier {
newTarget: string;
newTarget?: string;
oldTarget?: string;

@@ -46,6 +46,5 @@ }

private serializeRefUpdate(f);
private onRefUpdate(params);
private onSymbolicRefUpdate(params);
onRefUpdate(params: RefUpdateDownstreamParams): Promise<void>;
private getRepo(repoName);
dispose(): void;
}

@@ -15,2 +15,3 @@ "use strict";

const protocol_1 = require("./protocol");
const ref_1 = require("../ref");
var MergeStrategy;

@@ -32,8 +33,6 @@ (function (MergeStrategy) {

connection.onNotification(protocol_1.RefUpdateDownstreamRequest.type, params => this.onRefUpdate(params));
connection.onRequest(protocol_1.RefUpdateSymbolicRequest.type, params => this.onSymbolicRefUpdate(params));
connection.onNotification(protocol_1.RefUpdateSymbolicRequest.type, params => this.onSymbolicRefUpdate(params));
}
attachWorkspace(refID, workspace, mergeStrategy) {
return __awaiter(this, void 0, void 0, function* () {
if (!/^branch\//.test(refID.ref) && refID.ref !== "HEAD") {
if (!ref_1.isBranchRef(refID.ref) && !ref_1.isHeadRef(refID.ref)) {
throw new Error(`invalid Zap ref: ${JSON.stringify(refID.ref)} (no 'branch/' prefix)`);

@@ -50,3 +49,3 @@ }

this.workspaceRefListener = this.onDidUpdateSymbolicRef((e) => {
if (e.ref === "HEAD" && refspecs.indexOf(e.newTarget) === -1) {
if (ref_1.isHeadRef(e.ref) && e.newTarget && refspecs.indexOf(e.newTarget) === -1) {
refspecs = e.newTarget ? [refID.ref, e.newTarget] : [refID.ref];

@@ -75,3 +74,3 @@ this.repoWatch({

detachWorkspace(repo, ref) {
return this.getRepo(repo).getRef(ref).detachWorkspace();
return this.getRepo(repo).getRef(ref).detachWorkspace(true);
}

@@ -107,12 +106,18 @@ resetWorkspaceRefState(refID, workspace, mergeStrategy) {

onRefUpdate(params) {
return this.serializeRefUpdate(() => this.getRepo(params.repo).onRefUpdateFromUpstream(params));
return this.serializeRefUpdate(() => {
const refHandler = this.getRepo(params.repo).refs.get(params.ref);
const wasSymbolic = refHandler ? refHandler.isSymbolic() : false;
const oldTarget = refHandler && refHandler.isSymbolic() ? refHandler.target : undefined;
return this.getRepo(params.repo).onRefUpdateFromUpstream(params).then(() => {
if (wasSymbolic || (params.state && params.state.target)) {
this.symbolicRefUpdateEmitter.fire({
repo: params.repo,
ref: params.ref,
newTarget: params.state ? params.state.target : undefined,
oldTarget,
});
}
});
});
}
onSymbolicRefUpdate(params) {
return this.serializeRefUpdate(() => this.getRepo(params.repo).onSymbolicRefUpdateFromUpstream(params)).then(() => this.symbolicRefUpdateEmitter.fire({
repo: params.repo,
ref: params.ref,
newTarget: params.target,
oldTarget: params.oldTarget,
}));
}
getRepo(repoName) {

@@ -153,85 +158,12 @@ let repo = this.repos.get(repoName);

}
ref = new NonSymbolicRefHandler({ repo: this.repoName, ref: params.ref }, this.remoteClient, params.state || null);
ref = new RefHandler({ repo: this.repoName, ref: params.ref }, this.remoteClient, params.state || null);
this.refs.set(params.ref, ref);
}
if (!(ref instanceof NonSymbolicRefHandler)) {
if (!(ref instanceof RefHandler)) {
throw new Error("not yet implemented: updating a ref from symbolic to non-symbolic");
}
return ref.onUpdateFromUpstream(params);
}
onSymbolicRefUpdateFromUpstream(params) {
let ref = this.refs.get(params.ref);
if (!ref) {
ref = new SymbolicRefHandler({ repo: params.repo, ref: params.ref });
this.refs.set(params.ref, ref);
}
if (!(ref instanceof SymbolicRefHandler)) {
throw new Error("not yet implemented: updating a ref from symbolic to non-symbolic");
}
return ref.onUpdateFromUpstream(params, this.refs);
}
}
const STRICT_CONSISTENCY_CHECKING_OF_SYMBOLIC_REF_STATE = false;
class SymbolicRefHandler {
constructor(refID) {
this.refID = refID;
}
onUpdateFromUpstream(params, allRefs) {
if (params.ack) {
return Promise.resolve(void 0);
}
if (STRICT_CONSISTENCY_CHECKING_OF_SYMBOLIC_REF_STATE) {
if (typeof this.target === "string" && !params.oldTarget) {
throw new Error(`symbolic ref ${JSON.stringify(this.refID.ref)} update: no oldTarget value sent (target: ${JSON.stringify(this.target)})`);
}
if (this.target !== params.oldTarget) {
throw new Error(`symbolic ref ${JSON.stringify(this.refID.ref)} update: wrong oldTarget value sent (${JSON.stringify(this.target)} != ${JSON.stringify(params.oldTarget)})`);
}
}
this.target = params.target;
const newTargetHandler = allRefs.get(params.target);
const oldTargetHandler = this.targetHandler;
this.targetHandler = newTargetHandler;
if (this.workspace && oldTargetHandler !== newTargetHandler) {
if (oldTargetHandler) {
oldTargetHandler.detachWorkspace();
}
if (this.targetHandler) {
return this.targetHandler.attachWorkspace(this.workspace, this.mergeStrategy);
}
}
return Promise.resolve();
}
attachWorkspace(newWorkspace, mergeStrategy) {
return __awaiter(this, void 0, void 0, function* () {
if (this.workspace && this.workspace !== newWorkspace) {
this.detachWorkspace();
this.workspace = undefined;
}
this.workspace = newWorkspace;
this.mergeStrategy = mergeStrategy;
if (!this.targetHandler) {
return Promise.resolve();
}
return this.targetHandler.attachWorkspace(newWorkspace, mergeStrategy);
});
}
detachWorkspace() {
if (!this.workspace) {
throw new Error("no workspace attached");
}
if (this.targetHandler) {
this.targetHandler.detachWorkspace();
}
this.workspace = undefined;
this.mergeStrategy = undefined;
}
resetWorkspaceRefState(workspace, mergeStrategy) {
if (!this.targetHandler) {
return Promise.reject(new Error(`resetting workspace ref state for symbolic ref ${this.refID.repo} failed: target ref ${this.target} does not exist`));
}
return this.targetHandler.resetWorkspaceRefState(workspace, mergeStrategy);
}
}
class NonSymbolicRefHandler {
class RefHandler {
constructor(refID, remoteClient, state) {

@@ -262,8 +194,5 @@ this.refID = refID;

ref: this.refID.ref,
current: {
gitBase: this.state.gitBase,
gitBranch: this.state.gitBranch,
rev,
},
current: protocol_1.refPointerFrom(this.state),
op,
rev,
});

@@ -298,4 +227,11 @@ break;

}
isSymbolic() { return Boolean(this.target); }
resetWorkspaceRefState(workspace, mergeStrategy) {
return __awaiter(this, void 0, void 0, function* () {
if (this.isSymbolic()) {
if (!this.targetHandler) {
return Promise.reject(new Error(`resetting workspace ref state for symbolic ref ${this.refID.repo} failed: target ref ${this.target} does not exist`));
}
return this.targetHandler.resetWorkspaceRefState(workspace, mergeStrategy);
}
try {

@@ -305,15 +241,16 @@ yield this.remoteClient.onReady();

case MergeStrategy.LocalClobbersRemote:
this.state = yield this.remoteClient.sendRequest(protocol_1.WorkspaceResetRequest.type, {
const res = yield this.remoteClient.sendRequest(protocol_1.WorkspaceBranchCreateRequest.type, {
dir: this.refID.repo,
ref: this.refID.ref,
overwrite: true,
bufferFiles: workspace.allBufferFiles(),
});
yield this.ot.reset(this.state.history);
this.state = { data: res.data };
yield this.ot.reset(this.state.data && this.state.data.history ? this.state.data.history : []);
break;
case MergeStrategy.RemoteClobbersLocal:
yield this.ot.reset(this.state && this.state.history ? this.state.history : []);
yield workspace.reset(this.state && this.state.history ? this.state.history : []);
yield this.ot.reset(this.state && this.state.data && this.state.data.history ? this.state.data.history : []);
yield workspace.reset(this.state && this.state.data && this.state.data.history ? this.state.data.history : []);
break;
case MergeStrategy.FastForward:
yield workspace.updateHistory(this.state && this.state.history || []);
yield workspace.updateHistory(this.state && this.state.data.history || []);
break;

@@ -339,6 +276,21 @@ default:

this.detachWorkspace();
if (this.targetHandler) {
this.targetHandler.detachWorkspace(true);
}
}
this.workspace = newWorkspace;
this.mergeStrategy = mergeStrategy;
this.ot.apply = (op) => this.workspace.apply(op);
if (this.isSymbolic()) {
if (!this.targetHandler) {
console.log(`Unable to attachWorkspace for symbolic ref ${JSON.stringify(this.refID)} because target ref ${JSON.stringify(this.target)} does not yet exist. When it is created, the workspace will be attached.`);
return Promise.resolve();
}
return this.targetHandler.attachWorkspace(newWorkspace, mergeStrategy);
}
this.ot.apply = (op) => {
if (!this.workspace) {
throw new Error(`ref ${this.refID.ref} has no workspace (inconsistent state)`);
}
return this.workspace.apply(op);
};
this.workspace.onOp(op => this.onWorkspaceOp(op));

@@ -351,9 +303,18 @@ this.workspace.onReset(newOp => this.onWorkspaceReset(newOp));

}
detachWorkspace() {
if (!this.workspace) {
detachWorkspace(force) {
if (!this.workspace && !force) {
throw new Error("no workspace attached");
}
this.workspace.onOp(undefined);
this.workspace.onReset(undefined);
this.ot.apply = undefined;
if (this.isSymbolic()) {
if (this.targetHandler) {
this.targetHandler.detachWorkspace(true);
}
}
else {
if (this.workspace) {
this.workspace.onOp(undefined);
this.workspace.onReset(undefined);
}
this.ot.apply = undefined;
}
this.workspace = undefined;

@@ -369,4 +330,4 @@ this.mergeStrategy = undefined;

this.remoteClient.onReady().then(() => {
if (!this.state) {
throw new Error(`attempt to send ref/ update request from ref with uninitialized state: ${JSON.stringify(this.refID)} `);
if (!this.state || !this.state.data) {
throw new Error(`attempt to send ref/ update request from ref ${JSON.stringify(this.refID)} with unexpected state: ${JSON.stringify(this.state)} `);
}

@@ -378,5 +339,7 @@ this.remoteClient.sendRequest(protocol_1.RefUpdateUpstreamRequest.type, {

state: {
gitBase: this.state.gitBase,
gitBranch: this.state.gitBranch,
history: newOp ? [newOp] : [],
data: {
gitBase: this.state.data.gitBase,
gitBranch: this.state.data.gitBranch,
history: newOp ? [newOp] : [],
},
},

@@ -396,3 +359,3 @@ });

}
onUpdateFromUpstream(params) {
onUpdateFromUpstream(params, allRefs) {
return __awaiter(this, void 0, void 0, function* () {

@@ -405,11 +368,43 @@ if (params.ack) {

else if (params.state) {
if (this.mergeStrategy === MergeStrategy.LocalClobbersRemote && this.state) {
if (params.state.data) {
if (this.mergeStrategy === MergeStrategy.LocalClobbersRemote && this.state) {
}
else if (this.mergeStrategy === MergeStrategy.FastForward && this.state) {
if (this.workspace) {
if (!params.state.data || !params.state.data.history) {
yield this.workspace.reset([]);
}
else {
yield this.workspace.updateHistory(params.state.data.history);
}
}
}
else {
this.state = params.state;
yield this.ot.reset(params.state.data && params.state.data.history ? params.state.data.history : []);
if (this.workspace) {
yield this.workspace.reset(params.state.data && params.state.data.history ? params.state.data.history : []);
}
}
for (const [name, h] of Array.from(allRefs.entries())) {
if (h.isSymbolic() && h.target === this.refID.ref) {
if (h.workspace) {
console.log(`Symbolic ref ${JSON.stringify(name)} points to ${this.refID.ref}. Attaching ${name}'s workspace using merge strategy ${MergeStrategy[h.mergeStrategy]} (our merge strategy is ${MergeStrategy[this.mergeStrategy]}).`);
h.targetHandler = this;
yield h.attachWorkspace(h.workspace, h.mergeStrategy);
}
}
}
}
else if (this.mergeStrategy === MergeStrategy.FastForward && this.state) {
if (this.workspace) {
if (!params.state.history) {
yield this.workspace.reset([]);
else if (params.state.target) {
this.target = params.state.target;
const newTargetHandler = allRefs.get(params.state.target);
const oldTargetHandler = this.targetHandler;
this.targetHandler = newTargetHandler;
if (this.workspace && oldTargetHandler !== newTargetHandler) {
if (oldTargetHandler) {
oldTargetHandler.detachWorkspace();
}
else {
yield this.workspace.updateHistory(params.state.history);
if (this.targetHandler) {
yield this.targetHandler.attachWorkspace(this.workspace, this.mergeStrategy);
}

@@ -419,7 +414,3 @@ }

else {
this.state = params.state;
yield this.ot.reset(params.state.history || []);
if (this.workspace) {
yield this.workspace.reset(params.state.history || []);
}
throw new Error(`ref update: invalid state: ${JSON.stringify(params)} `);
}

@@ -426,0 +417,0 @@ }

@@ -37,3 +37,3 @@ "use strict";

ref: "branch/b",
state: { gitBase: "c", gitBranch: "d" },
state: { data: { gitBase: "c", gitBranch: "d" } },
});

@@ -47,4 +47,5 @@ });

ref: "branch/b",
current: { gitBase: "c", gitBranch: "d", rev: 0 },
current: { base: { gitBase: "c", gitBranch: "d" } },
op: { head: "a" },
rev: 0,
});

@@ -65,3 +66,3 @@ resolve();

ref: "branch/b",
state: { gitBase: "c", gitBranch: "d" },
state: { data: { gitBase: "c", gitBranch: "d" } },
});

@@ -82,3 +83,3 @@ const workspace = createMockWorkspace();

ref: "branch/b",
state: { gitBase: "c", gitBranch: "d" },
state: { data: { gitBase: "c", gitBranch: "d" } },
});

@@ -92,3 +93,3 @@ });

ref: "branch/b",
state: { gitBase: "c", gitBranch: "d" },
state: { data: { gitBase: "c", gitBranch: "d" } },
});

@@ -103,3 +104,3 @@ const workspace = createMockWorkspace();

ref: "branch/b",
current: { gitBase: "c", gitBranch: "d" },
current: { base: { gitBase: "c", gitBranch: "d" } },
ack: true,

@@ -106,0 +107,0 @@ op: {},

import { NotificationType, NotificationType0, RequestType, RequestType0 } from "vscode-jsonrpc";
import { WorkspaceOp } from "../ot/workspace";
import { BranchName } from "../ref";
export declare enum ErrorCode {

@@ -18,4 +19,6 @@ ErrorCodeInvalid = 0,

ErrorCodeWorkspaceIdentifierRequired = 13,
ErrorCodeRefUpdateInvalid = 14,
ErrorCodeInvalidOp = 15,
ErrorCodeWorkspaceStateConflict = 14,
ErrorCodeWorkspaceAlreadyOnBranch = 15,
ErrorCodeRefUpdateInvalid = 16,
ErrorCodeInvalidOp = 17,
}

@@ -114,15 +117,19 @@ export declare enum StatusType {

}
export interface RefBaseInfo {
export interface RefBase {
gitBase: string;
gitBranch: string;
}
export interface RefPointer extends RefBaseInfo {
rev: number;
export interface RefPointer {
base?: RefBase;
target?: string;
}
export interface RefState extends RefBaseInfo {
export declare function refPointerFrom(state: RefState | undefined): RefPointer | undefined;
export interface RefState {
data?: RefData;
target?: string;
}
export interface RefData extends RefBase {
history?: WorkspaceOp[];
}
export interface RefInfo extends RefIdentifier {
target?: string;
state?: RefState;
export interface RefInfo extends RefIdentifier, RefState {
watchers: string[];

@@ -144,6 +151,2 @@ }

}
export interface RefConfiguration {
upstream: string;
overwrite: boolean;
}
export interface RepoConfiguration {

@@ -154,5 +157,2 @@ workspace?: WorkspaceConfiguration;

};
refs: {
[ref: string]: RefConfiguration;
};
}

@@ -178,3 +178,2 @@ export interface RepoInfoParams {

export interface RefUpdateDownstreamParams extends RefIdentifier {
current?: RefBaseInfo;
state?: RefState;

@@ -192,5 +191,6 @@ op?: WorkspaceOp;

current?: RefPointer;
force?: boolean;
state?: RefState;
force?: boolean;
op?: WorkspaceOp;
rev?: number;
delete?: boolean;

@@ -203,12 +203,2 @@ }

}
export interface RefUpdateSymbolicParams extends RefIdentifier {
target: string;
oldTarget?: string;
ack?: boolean;
}
export interface RefUpdateSymbolicResult {
}
export declare namespace RefUpdateSymbolicRequest {
const type: RequestType<RefUpdateSymbolicParams, RefUpdateSymbolicResult, void, void>;
}
export interface WorkspaceIdentifier {

@@ -241,16 +231,41 @@ dir: string;

}
export interface WorkspaceStatusParams extends WorkspaceIdentifier, WorkspaceConfiguration {
}
export declare namespace WorkspaceStatusRequest {
const type: RequestType<WorkspaceStatusParams, ShowStatusParams, any, void>;
}
export interface WorkspaceResetParams extends WorkspaceIdentifier {
export interface WorkspaceBranchCreateParams extends WorkspaceIdentifier {
branch?: BranchName;
overwrite?: boolean;
bufferFiles: {
[fileName: string]: string;
};
ref: string;
}
export declare namespace WorkspaceResetRequest {
const type: RequestType<WorkspaceResetParams, RefState, any, void>;
export interface WorkspaceBranchCreateResult {
branch: BranchName;
data: RefData;
}
export declare namespace WorkspaceBranchCreateRequest {
const type: RequestType<WorkspaceBranchCreateParams, WorkspaceBranchCreateResult, any, void>;
}
export interface WorkspaceBranchSetParams extends WorkspaceIdentifier {
branch?: BranchName;
}
export declare namespace WorkspaceBranchSetRequest {
const type: RequestType<WorkspaceBranchSetParams, string, WorkspaceStateConflictError, void>;
}
export interface WorkspaceBranchCloseParams extends WorkspaceIdentifier {
}
export declare namespace WorkspaceBranchCloseRequest {
const type: RequestType<WorkspaceBranchCloseParams, void, any, void>;
}
export interface WorkspaceStateConflictError {
branch: BranchName;
dirtyGitWorktree: boolean;
requiredBase: RefBase;
currentBase: RefBase;
}
export interface WorkspaceStatusParams extends WorkspaceIdentifier, WorkspaceConfiguration {
}
export interface WorkspaceStatusResult {
head: string;
}
export declare namespace WorkspaceStatusRequest {
const type: RequestType<WorkspaceStatusParams, WorkspaceStatusResult, any, void>;
}
export interface WorkspaceWillSaveFileParams {

@@ -257,0 +272,0 @@ uri: string;

@@ -19,4 +19,6 @@ "use strict";

ErrorCode[ErrorCode["ErrorCodeWorkspaceIdentifierRequired"] = 13] = "ErrorCodeWorkspaceIdentifierRequired";
ErrorCode[ErrorCode["ErrorCodeRefUpdateInvalid"] = 14] = "ErrorCodeRefUpdateInvalid";
ErrorCode[ErrorCode["ErrorCodeInvalidOp"] = 15] = "ErrorCodeInvalidOp";
ErrorCode[ErrorCode["ErrorCodeWorkspaceStateConflict"] = 14] = "ErrorCodeWorkspaceStateConflict";
ErrorCode[ErrorCode["ErrorCodeWorkspaceAlreadyOnBranch"] = 15] = "ErrorCodeWorkspaceAlreadyOnBranch";
ErrorCode[ErrorCode["ErrorCodeRefUpdateInvalid"] = 16] = "ErrorCodeRefUpdateInvalid";
ErrorCode[ErrorCode["ErrorCodeInvalidOp"] = 17] = "ErrorCodeInvalidOp";
})(ErrorCode = exports.ErrorCode || (exports.ErrorCode = {}));

@@ -76,2 +78,15 @@ var StatusType;

})(TelemetryEventNotification = exports.TelemetryEventNotification || (exports.TelemetryEventNotification = {}));
function refPointerFrom(state) {
if (!state) {
return undefined;
}
if (state.data) {
return { base: { gitBase: state.data.gitBase, gitBranch: state.data.gitBranch } };
}
if (state.target) {
return { target: state.target };
}
throw new Error(`refPointerFrom: invalid state: ${JSON.stringify(state)}`);
}
exports.refPointerFrom = refPointerFrom;
var RefListRequest;

@@ -105,6 +120,2 @@ (function (RefListRequest) {

})(RefUpdateUpstreamRequest = exports.RefUpdateUpstreamRequest || (exports.RefUpdateUpstreamRequest = {}));
var RefUpdateSymbolicRequest;
(function (RefUpdateSymbolicRequest) {
RefUpdateSymbolicRequest.type = new vscode_jsonrpc_1.RequestType("ref/updateSymbolic");
})(RefUpdateSymbolicRequest = exports.RefUpdateSymbolicRequest || (exports.RefUpdateSymbolicRequest = {}));
;

@@ -123,2 +134,14 @@ var WorkspaceAddRequest;

})(WorkspaceConfigureRequest = exports.WorkspaceConfigureRequest || (exports.WorkspaceConfigureRequest = {}));
var WorkspaceBranchCreateRequest;
(function (WorkspaceBranchCreateRequest) {
WorkspaceBranchCreateRequest.type = new vscode_jsonrpc_1.RequestType("workspace/branch/create");
})(WorkspaceBranchCreateRequest = exports.WorkspaceBranchCreateRequest || (exports.WorkspaceBranchCreateRequest = {}));
var WorkspaceBranchSetRequest;
(function (WorkspaceBranchSetRequest) {
WorkspaceBranchSetRequest.type = new vscode_jsonrpc_1.RequestType("workspace/branch/set");
})(WorkspaceBranchSetRequest = exports.WorkspaceBranchSetRequest || (exports.WorkspaceBranchSetRequest = {}));
var WorkspaceBranchCloseRequest;
(function (WorkspaceBranchCloseRequest) {
WorkspaceBranchCloseRequest.type = new vscode_jsonrpc_1.RequestType("workspace/branch/close");
})(WorkspaceBranchCloseRequest = exports.WorkspaceBranchCloseRequest || (exports.WorkspaceBranchCloseRequest = {}));
var WorkspaceStatusRequest;

@@ -128,6 +151,2 @@ (function (WorkspaceStatusRequest) {

})(WorkspaceStatusRequest = exports.WorkspaceStatusRequest || (exports.WorkspaceStatusRequest = {}));
var WorkspaceResetRequest;
(function (WorkspaceResetRequest) {
WorkspaceResetRequest.type = new vscode_jsonrpc_1.RequestType("workspace/reset");
})(WorkspaceResetRequest = exports.WorkspaceResetRequest || (exports.WorkspaceResetRequest = {}));
var WorkspaceWillSaveFileRequest;

@@ -134,0 +153,0 @@ (function (WorkspaceWillSaveFileRequest) {

{
"name": "libzap",
"version": "0.0.98",
"version": "0.0.99",
"description": "JavaScript library for Zap",

@@ -5,0 +5,0 @@ "license": "none",

@@ -7,3 +7,4 @@ import { Disposable, Emitter, Event } from "vscode-jsonrpc";

import { IConnection } from "./connection";
import { RefIdentifier, RefInfoRequest, RefInfo, RefState, RefUpdateUpstreamRequest, RefUpdateSymbolicParams, RefUpdateSymbolicRequest, RefUpdateDownstreamRequest, RefUpdateDownstreamParams, RepoWatchParams, RepoWatchRequest, WorkspaceResetRequest, WorkspaceResetParams, WorkspaceWillSaveFileParams, WorkspaceWillSaveFileRequest } from "./protocol";
import { RefIdentifier, RefInfoRequest, RefInfo, RefState, RefUpdateUpstreamRequest, RefUpdateUpstreamParams, RefUpdateDownstreamRequest, RefUpdateDownstreamParams, RepoWatchParams, RepoWatchRequest, WorkspaceWillSaveFileParams, WorkspaceWillSaveFileRequest, WorkspaceBranchCreateRequest, WorkspaceBranchCreateParams, refPointerFrom } from "./protocol";
import { isBranchRef, isHeadRef } from "../ref";

@@ -39,3 +40,4 @@ export enum MergeStrategy {

export interface SymbolicRefUpdateEvent extends RefIdentifier {
newTarget: string;
// At least 1 of these fields is non-undefined.
newTarget?: string;
oldTarget?: string;

@@ -59,5 +61,2 @@ }

connection.onNotification(RefUpdateDownstreamRequest.type, params => this.onRefUpdate(params));
connection.onRequest(RefUpdateSymbolicRequest.type, params => this.onSymbolicRefUpdate(params));
connection.onNotification(RefUpdateSymbolicRequest.type, params => this.onSymbolicRefUpdate(params));
}

@@ -67,3 +66,3 @@

public async attachWorkspace(refID: RefIdentifier, workspace: Workspace, mergeStrategy: MergeStrategy): Promise<void> {
if (!/^branch\//.test(refID.ref) && refID.ref !== "HEAD") {
if (!isBranchRef(refID.ref) && !isHeadRef(refID.ref)) {
throw new Error(`invalid Zap ref: ${JSON.stringify(refID.ref)} (no 'branch/' prefix)`);

@@ -76,11 +75,12 @@ }

// If we're watching a symbolic ref (like "HEAD") and its
// target ref changes, then add its new target ref to our
// If we're watching a symbolic ref (like "head/$CLIENT") and
// its target ref changes, then add its new target ref to our
// watch refspecs so we can use the branch.
//
// This means that if we're watching HEAD, on initial start we
// will issue 2 repo/watches (the 1st for just "HEAD", and the
// 2nd soon thereafter with "HEAD" and its target ref when we
// realize "HEAD" is a symbolic ref). This is better than
// issuing a ref/info query to resolve "HEAD" prior to
// This means that if we're watching head/$CLIENT, on initial
// start we will issue 2 repo/watches (the 1st for just
// "head/$CLIENT", and the 2nd soon thereafter with
// "head/$CLIENT" and its target ref when we realize
// "head/$CLIENT" is a symbolic ref). This is better than
// issuing a ref/info query to resolve "head/$CLIENT" prior to
// repo/watch because that results in receiving the ref's

@@ -90,3 +90,3 @@ // entire history twice.

this.workspaceRefListener = this.onDidUpdateSymbolicRef((e: SymbolicRefUpdateEvent) => {
if (e.ref === "HEAD" && refspecs.indexOf(e.newTarget) === -1) {
if (isHeadRef(e.ref) && e.newTarget && refspecs.indexOf(e.newTarget) === -1) {
refspecs = e.newTarget ? [refID.ref, e.newTarget] : [refID.ref];

@@ -119,3 +119,3 @@ this.repoWatch({

public detachWorkspace(repo: string, ref: string): void {
return this.getRepo(repo).getRef(ref).detachWorkspace();
return this.getRepo(repo).getRef(ref).detachWorkspace(true);
}

@@ -163,19 +163,25 @@

private onRefUpdate(params: RefUpdateDownstreamParams): Promise<void> {
public onRefUpdate(params: RefUpdateDownstreamParams): Promise<void> {
return this.serializeRefUpdate(
() => this.getRepo(params.repo).onRefUpdateFromUpstream(params),
() => {
// Get previous values for SymbolicRefUpdateEvent.
const refHandler = this.getRepo(params.repo).refs.get(params.ref);
const wasSymbolic = refHandler ? refHandler.isSymbolic() : false;
const oldTarget = refHandler && refHandler.isSymbolic() ? refHandler.target : undefined;
// Handle ref update, then emit event if it's a symbolic ref update.
return this.getRepo(params.repo).onRefUpdateFromUpstream(params).then(() => {
if (wasSymbolic || (params.state && params.state.target)) {
this.symbolicRefUpdateEmitter.fire({
repo: params.repo,
ref: params.ref,
newTarget: params.state ? params.state.target : undefined,
oldTarget,
});
}
});
},
);
}
private onSymbolicRefUpdate(params: RefUpdateSymbolicParams): Promise<void> {
return this.serializeRefUpdate(
() => this.getRepo(params.repo).onSymbolicRefUpdateFromUpstream(params),
).then(() => this.symbolicRefUpdateEmitter.fire({
repo: params.repo,
ref: params.ref,
newTarget: params.target,
oldTarget: params.oldTarget,
}));
}
private getRepo(repoName: string): RepoHandler {

@@ -196,3 +202,3 @@ let repo = this.repos.get(repoName);

class RepoHandler {
private refs = new Map<string, RefHandler>();
public refs = new Map<string, RefHandler>();

@@ -218,20 +224,8 @@ constructor(

}
ref = new NonSymbolicRefHandler({ repo: this.repoName, ref: params.ref }, this.remoteClient, params.state || null);
ref = new RefHandler({ repo: this.repoName, ref: params.ref }, this.remoteClient, params.state || null);
this.refs.set(params.ref, ref);
}
if (!(ref instanceof NonSymbolicRefHandler)) {
if (!(ref instanceof RefHandler)) {
throw new Error("not yet implemented: updating a ref from symbolic to non-symbolic");
}
return ref.onUpdateFromUpstream(params);
}
public onSymbolicRefUpdateFromUpstream(params: RefUpdateSymbolicParams): Promise<void> {
let ref = this.refs.get(params.ref);
if (!ref) {
ref = new SymbolicRefHandler({ repo: params.repo, ref: params.ref });
this.refs.set(params.ref, ref);
}
if (!(ref instanceof SymbolicRefHandler)) {
throw new Error("not yet implemented: updating a ref from symbolic to non-symbolic");
}
return ref.onUpdateFromUpstream(params, this.refs);

@@ -247,14 +241,13 @@ }

const STRICT_CONSISTENCY_CHECKING_OF_SYMBOLIC_REF_STATE = false; // not currently viable without more conflict resolution impl
class RefHandler implements RefHandler {
private ot = new OTClient(); // for non-symbolic refs
class SymbolicRefHandler implements RefHandler {
private target?: string;
/**
* targetHandler is the RefHandler of the target ref. It is
* undefined if the target ref does not exist locally, which can
* happen if it's not being watched or if it just doesn't exist on
* the server either.
* targetHandler is the RefHandler of the target ref (if this
* RefHandler is for a symbolic ref). It is undefined if the
* target ref does not exist locally, which can happen if it's not
* being watched or if it just doesn't exist on the server either.
*/
private targetHandler?: RefHandler;
public target?: string; // for symbolic refs

@@ -266,75 +259,2 @@ private workspace?: Workspace;

private refID: RefIdentifier,
) { }
onUpdateFromUpstream(params: RefUpdateSymbolicParams, allRefs: Map<string, RefHandler>): Promise<void> {
if (params.ack) {
return Promise.resolve(void 0);
}
if (STRICT_CONSISTENCY_CHECKING_OF_SYMBOLIC_REF_STATE) {
if (typeof this.target === "string" && !params.oldTarget) {
throw new Error(`symbolic ref ${JSON.stringify(this.refID.ref)} update: no oldTarget value sent (target: ${JSON.stringify(this.target)})`);
}
if (this.target !== params.oldTarget) {
throw new Error(`symbolic ref ${JSON.stringify(this.refID.ref)} update: wrong oldTarget value sent (${JSON.stringify(this.target)} != ${JSON.stringify(params.oldTarget)})`);
}
}
this.target = params.target;
// The symbolic ref might point to a ref that we don't have
// locally (because we aren't watching it). We'll still record
// the target, and the other application code will probably
// update our watch refspec to fetch the target ref.
const newTargetHandler = allRefs.get(params.target);
const oldTargetHandler = this.targetHandler;
this.targetHandler = newTargetHandler;
if (this.workspace && oldTargetHandler !== newTargetHandler) {
if (oldTargetHandler) { oldTargetHandler.detachWorkspace(); }
if (this.targetHandler) { return this.targetHandler.attachWorkspace(this.workspace, this.mergeStrategy); }
}
return Promise.resolve();
}
public async attachWorkspace(newWorkspace: Workspace, mergeStrategy: MergeStrategy): Promise<void> {
if (this.workspace && this.workspace !== newWorkspace) {
this.detachWorkspace();
this.workspace = undefined;
}
this.workspace = newWorkspace;
this.mergeStrategy = mergeStrategy;
// If there is no target ref, then we must wait until there is
// one to call this.targetHandler.attachWorkspace.
if (!this.targetHandler) {
return Promise.resolve();
}
return this.targetHandler.attachWorkspace(newWorkspace, mergeStrategy);
}
public detachWorkspace(): void {
if (!this.workspace) {
throw new Error("no workspace attached");
}
if (this.targetHandler) { this.targetHandler.detachWorkspace(); }
this.workspace = undefined;
this.mergeStrategy = undefined;
}
public resetWorkspaceRefState(workspace: Workspace, mergeStrategy: MergeStrategy): Promise<void> {
if (!this.targetHandler) {
return Promise.reject(new Error(`resetting workspace ref state for symbolic ref ${this.refID.repo} failed: target ref ${this.target} does not exist`));
}
return this.targetHandler.resetWorkspaceRefState(workspace, mergeStrategy);
}
}
class NonSymbolicRefHandler implements RefHandler {
private ot = new OTClient();
private workspace?: Workspace;
private mergeStrategy?: MergeStrategy;
constructor(
private refID: RefIdentifier,
private remoteClient: Client,

@@ -365,9 +285,6 @@ private state: RefState | null,

ref: this.refID.ref,
current: {
gitBase: this.state!.gitBase,
gitBranch: this.state!.gitBranch,
rev,
},
current: refPointerFrom(this.state),
op,
});
rev,
} as RefUpdateUpstreamParams);
break;

@@ -402,3 +319,12 @@ } catch (err) {

public isSymbolic(): boolean { return Boolean(this.target); }
public async resetWorkspaceRefState(workspace: Workspace, mergeStrategy: MergeStrategy): Promise<void> {
if (this.isSymbolic()) {
if (!this.targetHandler) {
return Promise.reject(new Error(`resetting workspace ref state for symbolic ref ${this.refID.repo} failed: target ref ${this.target} does not exist`));
}
return this.targetHandler.resetWorkspaceRefState(workspace, mergeStrategy);
}
try {

@@ -408,17 +334,18 @@ await this.remoteClient.onReady();

case MergeStrategy.LocalClobbersRemote:
this.state = await this.remoteClient.sendRequest(WorkspaceResetRequest.type, {
const res = await this.remoteClient.sendRequest(WorkspaceBranchCreateRequest.type, {
dir: this.refID.repo,
ref: this.refID.ref,
overwrite: true,
bufferFiles: workspace.allBufferFiles(),
} as WorkspaceResetParams);
await this.ot.reset(this.state!.history);
} as WorkspaceBranchCreateParams);
this.state = { data: res.data };
await this.ot.reset(this.state.data && this.state.data.history ? this.state.data.history : []);
break;
case MergeStrategy.RemoteClobbersLocal:
await this.ot.reset(this.state && this.state.history ? this.state.history : []);
await workspace.reset(this.state && this.state.history ? this.state.history : []);
await this.ot.reset(this.state && this.state.data && this.state.data.history ? this.state.data.history : []);
await workspace.reset(this.state && this.state.data && this.state.data.history ? this.state.data.history : []);
break;
case MergeStrategy.FastForward:
await workspace.updateHistory(this.state && this.state.history || []);
await workspace.updateHistory(this.state && this.state.data!.history || []);
break;

@@ -446,2 +373,3 @@

this.detachWorkspace();
if (this.targetHandler) { this.targetHandler.detachWorkspace(true); }
}

@@ -451,3 +379,16 @@ this.workspace = newWorkspace;

this.ot.apply = (op) => this.workspace!.apply(op);
if (this.isSymbolic()) {
// If there is no target ref, then we must wait until there is
// one to call this.targetHandler.attachWorkspace.
if (!this.targetHandler) {
console.log(`Unable to attachWorkspace for symbolic ref ${JSON.stringify(this.refID)} because target ref ${JSON.stringify(this.target)} does not yet exist. When it is created, the workspace will be attached.`);
return Promise.resolve();
}
return this.targetHandler.attachWorkspace(newWorkspace, mergeStrategy);
}
this.ot.apply = (op) => {
if (!this.workspace) { throw new Error(`ref ${this.refID.ref} has no workspace (inconsistent state)`); }
return this.workspace.apply(op);
};
this.workspace.onOp(op => this.onWorkspaceOp(op));

@@ -462,9 +403,15 @@ this.workspace.onReset(newOp => this.onWorkspaceReset(newOp));

public detachWorkspace(): void {
if (!this.workspace) {
public detachWorkspace(force?: boolean): void {
if (!this.workspace && !force) {
throw new Error("no workspace attached");
}
this.workspace.onOp(undefined);
this.workspace.onReset(undefined);
this.ot.apply = undefined;
if (this.isSymbolic()) {
if (this.targetHandler) { this.targetHandler.detachWorkspace(true); }
} else {
if (this.workspace) {
this.workspace.onOp(undefined);
this.workspace.onReset(undefined);
}
this.ot.apply = undefined;
}
this.workspace = undefined;

@@ -481,4 +428,4 @@ this.mergeStrategy = undefined;

this.remoteClient.onReady().then(() => {
if (!this.state) {
throw new Error(`attempt to send ref/ update request from ref with uninitialized state: ${JSON.stringify(this.refID)} `);
if (!this.state || !this.state.data) {
throw new Error(`attempt to send ref/ update request from ref ${JSON.stringify(this.refID)} with unexpected state: ${JSON.stringify(this.state)} `);
}

@@ -490,7 +437,9 @@ this.remoteClient.sendRequest(RefUpdateUpstreamRequest.type, {

state: {
gitBase: this.state.gitBase,
gitBranch: this.state.gitBranch,
history: newOp ? [newOp] : [],
data: {
gitBase: this.state.data.gitBase,
gitBranch: this.state.data.gitBranch,
history: newOp ? [newOp] : [],
},
},
});
} as RefUpdateUpstreamParams);
}).then(() => { /* noop */ }, (err) => {

@@ -511,3 +460,3 @@ // TODO@ handle ops that didn't send properly

public async onUpdateFromUpstream(params: RefUpdateDownstreamParams): Promise<any> {
public async onUpdateFromUpstream(params: RefUpdateDownstreamParams, allRefs: Map<string, RefHandler>): Promise<any> {
if (params.ack) {

@@ -518,23 +467,58 @@ if (params.op) {

} else if (params.state) {
if (this.mergeStrategy === MergeStrategy.LocalClobbersRemote && this.state) {
// This means we've just reconnected to the server and
// received the repo/watch initial states for the
// refs. We don't want those remote states to clobber
// our local state, so ignore them.
} else if (this.mergeStrategy === MergeStrategy.FastForward && this.state) {
if (this.workspace) {
// If we receive an update with a null history, assume this update
// is a reset action.
if (!params.state.history) {
await this.workspace.reset([]);
} else {
await this.workspace.updateHistory(params.state.history);
if (params.state.data) {
// Non-symbolic ref.
if (this.mergeStrategy === MergeStrategy.LocalClobbersRemote && this.state) {
// This means we've just reconnected to the server and
// received the repo/watch initial states for the
// refs. We don't want those remote states to clobber
// our local state, so ignore them.
} else if (this.mergeStrategy === MergeStrategy.FastForward && this.state) {
if (this.workspace) {
// If we receive an update with a null history, assume this update
// is a reset action.
if (!params.state.data || !params.state.data.history) {
await this.workspace.reset([]);
} else {
await this.workspace.updateHistory(params.state.data.history);
}
}
} else {
this.state = params.state;
await this.ot.reset(params.state.data && params.state.data.history ? params.state.data.history : []);
if (this.workspace) {
await this.workspace.reset(params.state.data && params.state.data.history ? params.state.data.history : []);
}
}
// We might have symbolic refs that point to this
// just-created or just-reset non-symbolic
// ref. Trigger the actions that would've been
// triggered on the symbolic refs'
// onUpdateFromUpstream if this target ref had
// existed.
for (const [name, h] of Array.from(allRefs.entries())) {
if (h.isSymbolic() && h.target === this.refID.ref) {
if (h.workspace) {
console.log(`Symbolic ref ${JSON.stringify(name)} points to ${this.refID.ref}. Attaching ${name}'s workspace using merge strategy ${MergeStrategy[h.mergeStrategy!]} (our merge strategy is ${MergeStrategy[this.mergeStrategy!]}).`);
h.targetHandler = this; // TODO(sqs8): seems to cause more problems when we set this, but doing so makes sense
await h.attachWorkspace(h.workspace, h.mergeStrategy);
}
}
}
} else if (params.state.target) {
// Symbolic ref.
this.target = params.state.target;
// The symbolic ref might point to a ref that we don't have
// locally (because we aren't watching it). We'll still record
// the target, and the other application code will probably
// update our watch refspec to fetch the target ref.
const newTargetHandler = allRefs.get(params.state.target);
const oldTargetHandler = this.targetHandler;
this.targetHandler = newTargetHandler;
if (this.workspace && oldTargetHandler !== newTargetHandler) {
if (oldTargetHandler) { oldTargetHandler.detachWorkspace(); }
if (this.targetHandler) { await this.targetHandler.attachWorkspace(this.workspace, this.mergeStrategy); }
}
} else {
this.state = params.state;
await this.ot.reset(params.state.history || []);
if (this.workspace) {
await this.workspace.reset(params.state.history || []);
}
throw new Error(`ref update: invalid state: ${JSON.stringify(params)} `);
}

@@ -541,0 +525,0 @@ } else if (params.op) {

@@ -5,3 +5,3 @@ import * as assert from "assert";

import { Handler, MergeStrategy, Workspace } from "./handler";
import { RefUpdateDownstreamRequest, RefUpdateDownstreamParams, WorkspaceWillSaveFileParams } from "./protocol";
import { RefUpdateDownstreamRequest, RefUpdateDownstreamParams, RefUpdateUpstreamParams, WorkspaceWillSaveFileParams } from "./protocol";
import { assertResolved, createTestServer } from "./util";

@@ -40,7 +40,7 @@ import { WorkspaceOp } from "../ot/workspace";

ref: "branch/b",
state: { gitBase: "c", gitBranch: "d" },
state: { data: { gitBase: "c", gitBranch: "d" } },
} as RefUpdateDownstreamParams);
});
let ok = new Promise((resolve, reject) => {
server.onRequest("ref/update", (params) => {
server.onRequest("ref/update", (params: RefUpdateUpstreamParams) => {
try {

@@ -50,5 +50,6 @@ assert.deepEqual(params, {

ref: "branch/b",
current: { gitBase: "c", gitBranch: "d", rev: 0 },
current: { base: { gitBase: "c", gitBranch: "d" } },
op: { head: "a" },
});
rev: 0,
} as RefUpdateUpstreamParams);
resolve();

@@ -67,6 +68,6 @@ } catch (err) {

// Create ref.
(handler as any).onRefUpdate({
handler.onRefUpdate({
repo: "repo",
ref: "branch/b",
state: { gitBase: "c", gitBranch: "d" },
state: { data: { gitBase: "c", gitBranch: "d" } },
} as RefUpdateDownstreamParams);

@@ -90,3 +91,3 @@

ref: "branch/b",
state: { gitBase: "c", gitBranch: "d" },
state: { data: { gitBase: "c", gitBranch: "d" } },
} as RefUpdateDownstreamParams);

@@ -100,6 +101,6 @@ });

// Create ref.
(handler as any).onRefUpdate({
handler.onRefUpdate({
repo: "repo",
ref: "branch/b",
state: { gitBase: "c", gitBranch: "d" },
state: { data: { gitBase: "c", gitBranch: "d" } },
} as RefUpdateDownstreamParams);

@@ -117,3 +118,3 @@

ref: "branch/b",
current: { gitBase: "c", gitBranch: "d" },
current: { base: { gitBase: "c", gitBranch: "d" } },
ack: true,

@@ -120,0 +121,0 @@ op: {},

import { NotificationType, NotificationType0, RequestType, RequestType0 } from "vscode-jsonrpc";
import { WorkspaceOp } from "../ot/workspace";
import { BranchName } from "../ref";

@@ -25,4 +26,6 @@ /**

ErrorCodeWorkspaceIdentifierRequired = 13,
ErrorCodeRefUpdateInvalid = 14,
ErrorCodeInvalidOp = 15,
ErrorCodeWorkspaceStateConflict = 14,
ErrorCodeWorkspaceAlreadyOnBranch = 15,
ErrorCodeRefUpdateInvalid = 16,
ErrorCodeInvalidOp = 17,
}

@@ -288,3 +291,4 @@

export interface RefBaseInfo {
export interface RefBase {
// TODO(sqs8) sync with Go
gitBase: string;

@@ -294,13 +298,28 @@ gitBranch: string;

export interface RefPointer extends RefBaseInfo {
rev: number;
export interface RefPointer {
base?: RefBase;
target?: string;
}
export interface RefState extends RefBaseInfo {
export function refPointerFrom(state: RefState | undefined): RefPointer | undefined {
if (!state) { return undefined; }
if (state.data) {
return { base: { gitBase: state.data.gitBase, gitBranch: state.data.gitBranch } };
}
if (state.target) {
return { target: state.target };
}
throw new Error(`refPointerFrom: invalid state: ${JSON.stringify(state)}`);
}
export interface RefState {
data?: RefData;
target?: string;
}
export interface RefData extends RefBase {
history?: WorkspaceOp[]; // undefined is equivalent to empty array
}
export interface RefInfo extends RefIdentifier {
target?: string;
state?: RefState;
export interface RefInfo extends RefIdentifier, RefState {
watchers: string[];

@@ -327,11 +346,5 @@ }

export interface RefConfiguration {
upstream: string;
overwrite: boolean;
}
export interface RepoConfiguration {
workspace?: WorkspaceConfiguration;
remotes?: { [remote: string]: RepoRemoteConfiguration };
refs: { [ref: string]: RefConfiguration };
}

@@ -363,3 +376,2 @@

export interface RefUpdateDownstreamParams extends RefIdentifier {
current?: RefBaseInfo;
state?: RefState;

@@ -379,5 +391,6 @@ op?: WorkspaceOp;

current?: RefPointer;
force?: boolean;
state?: RefState;
force?: boolean;
op?: WorkspaceOp;
rev?: number;
delete?: boolean;

@@ -392,14 +405,2 @@ }

export interface RefUpdateSymbolicParams extends RefIdentifier {
target: string;
oldTarget?: string;
ack?: boolean;
}
export interface RefUpdateSymbolicResult { }
export namespace RefUpdateSymbolicRequest {
export const type = new RequestType<RefUpdateSymbolicParams, RefUpdateSymbolicResult, void, void>("ref/updateSymbolic");
}
// Workspace

@@ -439,17 +440,48 @@

export interface WorkspaceStatusParams extends WorkspaceIdentifier, WorkspaceConfiguration { }
export interface WorkspaceBranchCreateParams extends WorkspaceIdentifier {
branch?: BranchName;
overwrite?: boolean;
bufferFiles: { [fileName: string]: string }; // "#mydir/myfile.txt" -> unsaved file contents
}
export namespace WorkspaceStatusRequest {
export const type = new RequestType<WorkspaceStatusParams, ShowStatusParams, any, void>("workspace/status");
export interface WorkspaceBranchCreateResult {
branch: BranchName;
data: RefData;
}
export interface WorkspaceResetParams extends WorkspaceIdentifier {
bufferFiles: { [fileName: string]: string }; // "#mydir/myfile.txt" -> unsaved file contents
ref: string;
export namespace WorkspaceBranchCreateRequest {
export const type = new RequestType<WorkspaceBranchCreateParams, WorkspaceBranchCreateResult, any, void>("workspace/branch/create");
}
export namespace WorkspaceResetRequest {
export const type = new RequestType<WorkspaceResetParams, RefState, any, void>("workspace/reset");
export interface WorkspaceBranchSetParams extends WorkspaceIdentifier {
branch?: BranchName;
}
export namespace WorkspaceBranchSetRequest {
export const type = new RequestType<WorkspaceBranchSetParams, BranchName, WorkspaceStateConflictError, void>("workspace/branch/set");
}
export interface WorkspaceBranchCloseParams extends WorkspaceIdentifier { }
export namespace WorkspaceBranchCloseRequest {
export const type = new RequestType<WorkspaceBranchCloseParams, void, any, void>("workspace/branch/close");
}
export interface WorkspaceStateConflictError {
branch: BranchName;
dirtyGitWorktree: boolean;
requiredBase: RefBase;
currentBase: RefBase;
}
export interface WorkspaceStatusParams extends WorkspaceIdentifier, WorkspaceConfiguration { }
export interface WorkspaceStatusResult {
head: string;
}
export namespace WorkspaceStatusRequest {
export const type = new RequestType<WorkspaceStatusParams, WorkspaceStatusResult, any, void>("workspace/status");
}
export interface WorkspaceWillSaveFileParams {

@@ -456,0 +488,0 @@ uri: string;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc