AIFlow API Documentation
    Preparing search index...

    Class GitService

    Git operations service

    Index

    Methods

    • Add specific file to staging area

      Parameters

      • filePath: string

        File path to add

      Returns void

    • Add multiple files to staging area

      Parameters

      • filePaths: string[]

        Array of file paths to add

      • batchSize: number = 1000

      Returns void

    • Safely checkout to the specified branch with the following steps:

      1. Automatically stash working directory and staged changes (including untracked files)
      2. Fetch remote branch and validate its existence
      3. If local branch exists: checkout and attempt fast-forward to remote/
        • Only fast-forward (--ff-only) to avoid merge commits
        • If fast-forward fails, preserve current commit with warning
      4. If local branch doesn't exist: create tracking branch from remote/
      5. Finally attempt stash pop (if conflicts occur, preserve and prompt for manual resolution)

      Parameters

      • branchName: string

        The name of the branch to checkout

      Returns void

    • Commit staged changes

      Parameters

      • message: string

        Commit message

      Returns void

    • Create branch, commit and push (legacy method)

      Parameters

      • branch: string

        Branch name

      • message: string

        Commit message

      Returns boolean

    • Create a new branch

      Parameters

      • branchName: string

        Branch name to create

      Returns void

    • Extract base URL from Git remote URL with protocol detection

      Parameters

      • OptionalremoteUrl: string

        Git remote URL (optional, will get current remote if not provided)

      Returns Promise<string>

      Base URL (e.g., "https://github.com", "https://gitlab.example.com")

    • Extract hostname from Git remote URL

      Parameters

      • OptionalremoteUrl: string

        Git remote URL (optional, will get current remote if not provided)

      Returns string

      Hostname (e.g., 'github.com', 'gitlab.example.com')

    • Force re-detection of protocol for hostname (asynchronous)

      Parameters

      • hostname: string

        The hostname to re-detect

      Returns Promise<string>

      Promise

    • Get the most likely parent branch of the current branch

      Returns null | string

      Base branch name or null if not found or in detached HEAD

    • Get simplified branch graph visualization (similar to GitLens)

      Parameters

      • limit: number = 20

        Maximum number of commits to show (default: 20)

      Returns string

      String representation of branch graph

    • Get list of changed files between two branches

      Parameters

      • baseBranch: string

        Base branch name

      • targetBranch: string

        Target branch name

      Returns string[]

      Array of changed file paths

    • Get detected protocol for hostname (synchronous, may return cached result)

      Parameters

      • hostname: string

        The hostname to check

      Returns Promise<string>

      Base URL with detected protocol

    • Get diff between two branches

      Parameters

      • baseBranch: string

        Base branch name

      • targetBranch: string

        Target branch name

      Returns string

      Git diff output between branches

    • Get git diff of specific files (unstaged changes)

      Parameters

      • filePaths: string[]

        Array of file paths to check diff for

      Returns string

      Git diff output

    • Get merge-base commit hash between current branch and target branch

      Parameters

      • otherBranch: string

        Target branch name

      Returns null | string

      Merge-base commit hash or null if not found

    • Gets the default remote name for the current repository. Tries to detect the most appropriate remote in the following order:

      1. 'origin' (most common)
      2. 'upstream' (common in fork workflows)
      3. First available remote

      Returns string

      The default remote name or 'origin' as fallback

    • Get remote URL for specified remote

      Parameters

      • OptionalremoteName: string

      Returns string

    • Get target branch for merge request (default branch or fallback)

      Returns string

      Target branch name

    • Check if a remote branch exists

      Parameters

      • branchName: string

        Branch name to check (e.g., 'origin/main')

      Returns boolean

      True if branch exists, false otherwise

    • Parse project path from Git remote URL

      Parameters

      • OptionalremoteUrl: string

        Git remote URL (optional, will get current remote if not provided)

      Returns null | string

      Project path (e.g., "user/repo")

    • Push current branch to remote

      Parameters

      • branchName: string

        Branch name to push

      Returns void

    • Get git repository status for all files

      Returns GitFileStatus[]

      Array of GitFileStatus objects representing file changes

    • Clear protocol cache for a specific hostname or all hostnames

      Parameters

      • Optionalhostname: string

        Optional hostname to clear, if not provided clears all cache

      Returns void

    • Get current protocol cache (for debugging)

      Returns Record<string, string>

      Copy of current cache entries