ogit
Version:
A lazy developer's Git CLI made simple. Makes using git on cloud IDEs (i.e. C9) a walk in the park.
299 lines (298 loc) • 9.19 kB
TypeScript
import { GitStatus } from '../models/GitStatus';
import * as SimpleGit from 'simple-git/promise';
import { GitBranch, GitFile } from '../models';
import { GitStash } from '../models/GitStash';
/**
* Wrapper class for git commands.
*
* @export
* @class GitFacade
*/
export declare namespace GitFacade {
const git: () => Promise<SimpleGit.SimpleGit>;
/**
* Returns the status of the current git repo.
*
* @static
* @memberof GitFacade
*/
const status: () => Promise<GitStatus>;
/**
* Returns the remote origin url for this branch.
*
* @static
* @memberof GitFacade
*/
const originUrl: () => Promise<string>;
/**
* Initializes the current directory as a git repo if not already.
*
* @static
* @memberof GitFacade
*/
const initialize: () => Promise<boolean>;
/**
* Sets up the git project from in the current directory. Works the same as
* cloning except that cloning requires a new directory be created and
* the code checked out in that.
*
* By default, this operation will pull the master branch.
*
* TODO: How to test this method?
*
* @static
* @memberof GitFacade
*/
const checkoutRepo: (url: string) => Promise<void>;
/**
* Returns the list of branches in the current repo.
*
* @static
* @memberof GitFacade
*/
const listBranches: () => Promise<GitBranch[]>;
/**
* Commits the files into repo.
*/
const commit: (message: string, fileNames: string[], skipValidation: boolean) => Promise<SimpleGit.CommitSummary>;
/**
* Pushes the local commits to the remote branch
* @param branchName the remote branch name
*/
const push: (branchNames: string[]) => Promise<void>;
/**
* Add the file to source control.
*
* @static
* @memberof GitFacade
*/
const addToRepo: (filePath: string) => Promise<void>;
/**
* Optimizes the repo by calling garbage collection
*/
const optimizeRepo: () => Promise<void>;
/**
* Ammends the last commit
*
* @static
* @memberof GitFacade
*/
const ammendLastCommit: (filePaths: string[], message: string) => Promise<SimpleGit.CommitSummary>;
/**
* Returns the last commit message from the commits
*
* @static
* @memberof GitFacade
*/
const getLastCommitMessage: () => Promise<string>;
/**
* Return file names in an string array from the last commit
*
* @static
* @memberof GitFacade
*/
const getFileNamesFromCommit: (commitHash: string) => Promise<string[]>;
/**
* Returns the last commit hash from the commits
*
* @static
* @memberof GitFacade
*/
const getLastCommitHash: () => Promise<string>;
/**
* Returns the commit message by looking up the hash in repo
*
* @static
* @memberof GitFacade
*/
const getMessageFromCommitHash: (hash: string) => Promise<string>;
/**
* Reverts a commit using the commit hash. It does not delete the files
*
* @static
* @memberof GitFacade
*/
const revertCommit: (hash: string) => Promise<void>;
/**
* Reverts a commit using the commit hash. It does not delete the files
*
* @static
* @memberof GitFacade
*/
const deleteCommit: (hash: string) => Promise<void>;
/**
* Creates a local branch from a remote branch
*
* @static
* @memberof GitFacade
*/
const createBranch: (branchName: string, remoteBranchName: string) => Promise<void>;
/**
* Renames a local branch
*
* @static
* @memberof GitFacade
*/
const renameBranch: (currantName: string, newName: string) => Promise<void>;
/**
* Switches to the local branch
* TODO: missing unit test...
*
* @static
* @memberof GitFacade
*/
const switchBranch: (branchName: string) => Promise<void>;
/**
* Returns the current branch name
*
* @static
* @memberof GitFacade
*/
const getCurrentBranchName: () => Promise<string>;
/**
* Deletes a branch from local repo
*/
const deleteLocalBranch: (branchName: string) => Promise<void>;
/**
* Deletes a remote branch
*/
const deleteRemoteBranch: (branchName: string) => Promise<void>;
/**
* Clears the stash by removing all entries
*
*/
const clearStash: () => Promise<void>;
/**
* Returns the list of stash names and the files attached to the stashes
*/
const getStashes: () => Promise<GitStash[]>;
/**
* Deletes a stash based on the number supplied
* @param stashNumber Stash number to delete
*/
const deleteStash: (stashNumber: number, message: string) => Promise<void>;
/**
* Removes a stash from local repo
*/
const unstash: (stashNumber: number, message: string, remove?: boolean) => Promise<void>;
/**
* Creates a new stash of the files
* @param message to add for the stash
* @param fileNames the list of file names
* @param partial is this a partial list or not
*/
const stash: (message: string, fileNames: string[], partial?: boolean) => Promise<void>;
/**
* Synchronises the remote branches
*/
const syncRemoteBranches: () => Promise<void>;
/**
* Reverts the changes to a file.
* @param file the path to the file
*/
const revertFile: (file: GitFile) => Promise<void>;
/**
* Returns a list of tag names for the repo
*/
const tags: () => Promise<SimpleGit.TagResult>;
/**
* Resets the current repo.
*
* @param pointer tag or branch name to set HEAD to
* @param strategy strategy to take
*/
const reset: (pointer: string, strategy: string) => Promise<void>;
/**
* Returns the list of file names that have merge conflict.
*/
const filesWithMergeConflicts: () => Promise<string[]>;
/**
* Pulls the changes from the remote branch into current.
* @param branch the remote branch to pull changes from. Defaults to the origin branch
*/
const pullRemoteChanges: (branch?: string) => Promise<void>;
/**
* Accept merge changes.
* @param acceptRemote should use remote or local changes
* @param filePath
*/
const acceptChanges: (acceptRemote: boolean, filePath?: string) => Promise<void>;
const autoCommit: (message: string) => Promise<SimpleGit.CommitSummary>;
/**
* Cancels the merge operation.
*/
const cancelMerge: () => Promise<void>;
/**
* Merges the brnach into the current branch
* @param branchName the source branch to merge
*/
const merge: (branchName: string, message?: string) => Promise<void>;
/**
* Sets the config value
* @param config the config to set
* @param value the value to set
* @param global if its global or not
*/
const setConfig: (config: string, value: string, global: boolean) => Promise<void>;
/**
* Returns the config value
* @param config to look for
* @param global if global config or not
*/
const getConfig: (config: string, global: boolean) => Promise<string>;
/**
* Returns the config data
* @param config name of the config
* @param global lookup in global scope?
*/
const getConfigData: (config: string, global?: boolean) => Promise<string>;
/**
* Returns the config data by looking into local config first and then global config
* @param config name of the config
*/
const getConfigDataFromAnyWhere: (config: string) => Promise<string>;
/**
* Sets the config data
* @param config name of the config
* @param value value of the config
* @param global lookup in global scope?
*/
const setConfigData: (config: string, value: string, global?: boolean) => Promise<void>;
/**
* Generates SSH Key pairs.
* @param options
*/
const generateSSHKeys: (options: any) => Promise<any>;
/**
* Clones a remote repo into the directory
*
* @param url of the remote repo
* @param dirName to clone to
*/
const cloneRepo: (url: string, dirName: string, reference?: string) => Promise<void>;
const listRemoteReferences: (url: string) => Promise<any[]>;
/**
* Adds a tag to the current repo. Only does annotated tagging.
* @param name the name of the tag
* @param message message for the tag
*/
const addTag: (name: string, message: string) => Promise<void>;
/**
* Pushes a tag to origin
* @param tagName the tag name to push
*/
const pushTag: (tagName: string) => Promise<void>;
/**
* Pushes all the tags to origin
* @param tagName the tag name to push
*/
const pushAllTags: () => Promise<void>;
/**
* Deletes the tag from local repo
*/
const deleteLocalTag: (tagName: string) => Promise<void>;
/**
* Deletes the tag from remote repo
*/
const deleteRemoteTag: (tagName: string) => Promise<void>;
}