@jupyterlab/git
Version:
A JupyterLab extension for version control using git
127 lines (126 loc) • 4.86 kB
JavaScript
import { ServerConnection } from '@jupyterlab/services';
import { Token } from '@lumino/coreutils';
export const EXTENSION_ID = 'jupyter.extensions.git_plugin';
export const IGitExtension = new Token(EXTENSION_ID);
export var Git;
(function (Git) {
let Diff;
(function (Diff) {
let SpecialRef;
(function (SpecialRef) {
// Working version
SpecialRef[SpecialRef["WORKING"] = 0] = "WORKING";
// Index version
SpecialRef[SpecialRef["INDEX"] = 1] = "INDEX";
// Common ancestor version (useful for unmerged files)
SpecialRef[SpecialRef["BASE"] = 2] = "BASE";
})(SpecialRef = Diff.SpecialRef || (Diff.SpecialRef = {}));
})(Diff = Git.Diff || (Git.Diff = {}));
/**
* Git repository state
*/
let State;
(function (State) {
/**
* Default state
*/
State[State["DEFAULT"] = 0] = "DEFAULT";
/**
* Detached head state
*/
State[State["DETACHED"] = 1] = "DETACHED";
/**
* Merge in progress
*/
State[State["MERGING"] = 2] = "MERGING";
/**
* Rebase in progress
*/
State[State["REBASING"] = 3] = "REBASING";
/**
* Cherry-pick in progress
*/
State[State["CHERRY_PICKING"] = 4] = "CHERRY_PICKING";
})(State = Git.State || (Git.State = {}));
/**
* A wrapped error for a fetch response.
*/
class GitResponseError extends ServerConnection.ResponseError {
/**
* Create a new response error.
*/
constructor(response, message = `Invalid response: ${response.status} ${response.statusText}`, traceback = '', json = {}) {
super(response, message);
this.traceback = traceback; // traceback added in mother class in 2.2.x
this._json = json !== null && json !== void 0 ? json : {};
}
/**
* The error response JSON body
*/
get json() {
return this._json;
}
}
Git.GitResponseError = GitResponseError;
class NotInRepository extends Error {
constructor() {
super('Not in a Git Repository');
}
}
Git.NotInRepository = NotInRepository;
class HiddenFile extends Error {
constructor() {
super('File is hidden');
this.name = 'hiddenFile';
this.message = 'File is hidden and cannot be accessed.';
}
}
Git.HiddenFile = HiddenFile;
})(Git || (Git = {}));
/**
* The command IDs used in the git context menus.
*/
export var ContextCommandIDs;
(function (ContextCommandIDs) {
ContextCommandIDs["gitCommitAmendStaged"] = "git:context-commitAmendStaged";
ContextCommandIDs["gitFileAdd"] = "git:context-add";
ContextCommandIDs["gitFileDiff"] = "git:context-diff";
ContextCommandIDs["gitFileDiscard"] = "git:context-discard";
ContextCommandIDs["gitFileDelete"] = "git:context-delete";
ContextCommandIDs["gitFileOpen"] = "git:context-open";
ContextCommandIDs["gitFileUnstage"] = "git:context-unstage";
ContextCommandIDs["gitFileStage"] = "git:context-stage";
ContextCommandIDs["gitFileTrack"] = "git:context-track";
ContextCommandIDs["gitFileHistory"] = "git:context-history";
ContextCommandIDs["gitIgnore"] = "git:context-ignore";
ContextCommandIDs["gitIgnoreExtension"] = "git:context-ignoreExtension";
ContextCommandIDs["gitNoAction"] = "git:no-action";
ContextCommandIDs["openFileFromDiff"] = "git:open-file-from-diff";
ContextCommandIDs["gitFileStashPop"] = "git:context-stash-pop";
ContextCommandIDs["gitTagAdd"] = "git:context-tag-add";
})(ContextCommandIDs || (ContextCommandIDs = {}));
/**
* The command IDs used by the git plugin.
*/
export var CommandIDs;
(function (CommandIDs) {
CommandIDs["gitUI"] = "git:ui";
CommandIDs["gitTerminalCommand"] = "git:terminal-command";
CommandIDs["gitInit"] = "git:init";
CommandIDs["gitOpenUrl"] = "git:open-url";
CommandIDs["gitToggleSimpleStaging"] = "git:toggle-simple-staging";
CommandIDs["gitManageRemote"] = "git:manage-remote";
CommandIDs["gitClone"] = "git:clone";
CommandIDs["gitMerge"] = "git:merge";
CommandIDs["gitOpenGitignore"] = "git:open-gitignore";
CommandIDs["gitPush"] = "git:push";
CommandIDs["gitPull"] = "git:pull";
CommandIDs["gitRebase"] = "git:rebase";
CommandIDs["gitResolveRebase"] = "git:resolve-rebase";
CommandIDs["gitResetToRemote"] = "git:reset-to-remote";
CommandIDs["gitSubmitCommand"] = "git:submit-commit";
CommandIDs["gitShowDiff"] = "git:show-diff";
CommandIDs["gitStash"] = "git:stash";
CommandIDs["gitStashPop"] = "git:stash-pop";
CommandIDs["gitStashList"] = "git:stash-list";
})(CommandIDs || (CommandIDs = {}));