import { GitgraphCore } from "../gitgraph"; import { GitgraphCommitOptions, GitgraphBranchOptions, GitgraphTagOptions } from "./gitgraph-user-api"; import { Branch } from "../branch"; import { Omit } from "../utils"; export { BranchUserApi, GitgraphMergeOptions }; interface GitgraphMergeOptions { /** * Branch or branch name. */ branch: string | BranchUserApi; /** * If `true`, perform a fast-forward merge (if possible). */ fastForward?: boolean; /** * Commit options. */ commitOptions?: GitgraphCommitOptions; } declare type BranchTagOptions = Omit, ["ref"]>; declare class BranchUserApi { /** * Name of the branch. * It needs to be public to be used when we merge another branch. */ readonly name: Branch["name"]; private _branch; private _graph; private _onGraphUpdate; constructor(branch: Branch, graph: GitgraphCore, onGraphUpdate: () => void); /** * Create a new branch (as `git branch`). * * @param options Options of the branch */ branch(options: Omit, "from">): BranchUserApi; /** * Create a new branch (as `git branch`). * * @param name Name of the created branch */ branch(name: string): BranchUserApi; /** * Add a new commit in the branch (as `git commit`). * * @param subject Commit subject */ commit(subject?: string): this; /** * Add a new commit in the branch (as `git commit`). * * @param options Options of the commit */ commit(options?: GitgraphCommitOptions): this; /** * Delete the branch (as `git branch -d`) */ delete(): this; /** * Create a merge commit. * * @param branch Branch * @param subject Merge commit message */ merge(branch: BranchUserApi, subject?: string): this; /** * Create a merge commit. * * @param branchName Branch name * @param subject Merge commit message */ merge(branchName: string, subject?: string): this; /** * Create a merge commit. * * @param options Options of the merge */ merge(options: GitgraphMergeOptions): this; /** * Tag the last commit of the branch. * * @param options Options of the tag */ tag(options: BranchTagOptions): this; /** * Tag the last commit of the branch. * * @param name Name of the tag */ tag(name: BranchTagOptions["name"]): this; /** * Checkout onto this branch and update "HEAD" in refs */ checkout(): this; private _commitWithParents; private _areCommitsConnected; private _fastForwardTo; private _getCommitStyle; private _isReferenced; }