Skip to main content

Git

Hierarchy

  • EventEmitter
    • Git

Implements

Index

Constructors

constructor

  • new Git(repoDir: string | (dir?: string) => string, options?: GitOptions): Git
  • Handles invoking the git-*-pack binaries


    Parameters

    • repoDir: string | (dir?: string) => string

      Create a new repository collection from the directory repoDir. repoDir should be entirely empty except for git repo directories. If repoDir is a function, repoDir(repo) will be used to dynamically resolve project directories. The return value of repoDir(repo) should be a string path specifying where to put the string repo. Make sure to return the same value for repo every time since repoDir(repo) will be called multiple times.

    • options: GitOptions = {}

      options that can be applied on the new instance being created

    Returns Git

Properties

authenticate

authenticate: undefined | (options: GitAuthenticateOptions, callback: (error?: Error) => undefined | void) => undefined | void | Promise<undefined | void | Error>

autoCreate

autoCreate: boolean

checkout

checkout: undefined | boolean

dirMap

dirMap: (dir?: string) => string

Type declaration

    • (dir?: string): string
    • Parameters

      • optionaldir: string

      Returns string

server

server: undefined | Server | Server

Methods

close

  • close(): Promise<string>
  • closes the server instance


    Returns Promise<string>

create

  • create(repo: string, callback: (error?: Error) => void): void
  • Create a new bare repository repoName in the instance repository directory.


    Parameters

    • repo: string

      the name of the repo

    • callback: (error?: Error) => void

      Optionally get a callback cb(err) to be notified when the repository was created.

    Returns void

exists

  • exists(repo: string): boolean
  • Find out whether repoName exists in the callback cb(exists).


    Parameters

    • repo: string

      name of the repo

    Returns boolean

getType

  • getType(service: string): string
  • returns the typeof service being process. This will respond with either fetch or push.


    Parameters

    • service: string

      the service type

    Returns string

handle

  • handle(req: IncomingMessage, res: ServerResponse): void
  • Handle incoming HTTP requests with a connect-style middleware


    Parameters

    • req: IncomingMessage
    • res: ServerResponse

    Returns void

list

  • list(callback: (error: undefined | Error, repos?: string[]) => void): void
  • list(): Promise<string[]>
  • Get a list of all the repositories


    Parameters

    • callback: (error: undefined | Error, repos?: string[]) => void

      function to be called when repositories have been found function(error, repos)

    Returns void

listen

  • listen(port: number, options?: GitServerOptions, callback?: () => void): Git
  • starts a git server on the given port


    Parameters

    • port: number

      the port to start the server on

    • optionaloptions: GitServerOptions

      the options to add extended functionality to the server

    • optionalcallback: () => void

      the function to call when server is started or error has occurred

    Returns Git

mkdir

  • mkdir(dir: string): void
  • Create a subdirectory dir in the repo dir with a callback.


    Parameters

    • dir: string

      directory name

    Returns void