@jupyterlab/git
Version:
A JupyterLab extension for version control using git
93 lines (92 loc) • 3.5 kB
TypeScript
import { JupyterFrontEnd } from '@jupyterlab/application';
import { IEditorFactoryService } from '@jupyterlab/codeeditor';
import { IEditorLanguageRegistry } from '@jupyterlab/codemirror';
import { FileBrowser, FileBrowserModel } from '@jupyterlab/filebrowser';
import { Contents } from '@jupyterlab/services';
import { ISettingRegistry } from '@jupyterlab/settingregistry';
import { ITranslator, TranslationBundle } from '@jupyterlab/translation';
import { ContextMenuSvg } from '@jupyterlab/ui-components';
import { CommandRegistry } from '@lumino/commands';
import { Menu } from '@lumino/widgets';
import { GitExtension } from './model';
import { ContextCommandIDs, Git, IGitExtension } from './tokens';
export interface IGitCloneArgs {
/**
* Path in which to clone the Git repository
*/
path: string;
/**
* Git repository url
*/
url: string;
/**
* Whether to activate git versioning in the clone or not.
* If false, this will remove the .git folder after cloning.
*/
versioning?: boolean;
/**
* Whether to activate git recurse submodules clone or not.
*/
submodules?: boolean;
}
/**
* Git operations requiring authentication
*/
export declare enum Operation {
Clone = "Clone",
Pull = "Pull",
Push = "Push",
ForcePush = "ForcePush",
Fetch = "Fetch"
}
interface IFileDiffArgument {
context?: Git.Diff.IContext;
filePath: string;
isText: boolean;
status?: Git.Status;
isPreview?: boolean;
previousFilePath?: string;
}
export declare namespace CommandArguments {
interface IGitFileDiff {
files: IFileDiffArgument[];
}
interface IGitContextAction {
files: Git.IStatusFile[];
}
interface IGitCommitInfo {
commit: Git.ISingleCommitInfo;
}
}
/**
* Add the commands for the git extension.
*/
export declare function addCommands(app: JupyterFrontEnd, gitModel: GitExtension, editorFactory: IEditorFactoryService, languageRegistry: IEditorLanguageRegistry, fileBrowserModel: FileBrowserModel, settings: ISettingRegistry.ISettings, translator: ITranslator): void;
/**
* Adds commands and menu items.
*
* @param commands - Jupyter App commands registry
* @param trans - language translator
* @returns menu
*/
export declare function createGitMenu(commands: CommandRegistry, trans: TranslationBundle): Menu;
export declare function addMenuItems(commands: ContextCommandIDs[], contextMenu: Menu, selectedFiles: Git.IStatusFile[]): void;
export declare function addHistoryMenuItems(commands: ContextCommandIDs[], contextMenu: Menu, selectedCommit: Git.ISingleCommitInfo): void;
/**
* Populate Git context submenu depending on the selected files.
*/
export declare function addFileBrowserContextMenu(model: IGitExtension, filebrowser: FileBrowser, contents: Contents.IManager, contextMenu: ContextMenuSvg, trans: TranslationBundle): void;
/**
* Handle Git operation that may require authentication.
*
* @private
* @param model - Git extension model
* @param operation - Git operation name
* @param trans - language translator
* @param args - Git operation arguments
* @param authentication - Git authentication information
* @param retry - Is this operation retried?
* @returns Promise for displaying a dialog
*/
export declare function showGitOperationDialog<T>(model: IGitExtension, operation: Operation, trans: TranslationBundle, args?: T, authentication?: Git.IAuth, retry?: boolean): Promise<string>;
export {};