git_tools

package
v0.0.33 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package git_tools provides utilities for interacting with Git repositories.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoCommitDiffViewChanges

func AutoCommitDiffViewChanges(ctx context.Context, repoDir, filePath string) error

AutoCommitDiffViewChanges automatically commits changes to the specified file If the last commit message is exactly "User changes from diff view.", it amends the commit Otherwise, it creates a new commit

func GitCat

func GitCat(repoDir, filePath string) (string, error)

GitCat returns the contents of a file in the repository at the given path This is used to get the current working copy of a file (not using git show)

func GitGetUntrackedFiles added in v0.0.14

func GitGetUntrackedFiles(repoDir string) ([]string, error)

GitGetUntrackedFiles returns a list of untracked files in the repository

func GitSaveFile

func GitSaveFile(repoDir, filePath, content string) error

GitSaveFile saves content to a file in the repository, checking first that it's tracked by git This prevents writing to files outside the repository

func GitShow

func GitShow(repoDir, hash string) (string, error)

GitShow returns the result of git show for a specific commit hash

Types

type DiffFile

type DiffFile struct {
	Path      string `json:"path"`
	OldPath   string `json:"old_path"` // Original path for renames and copies
	OldMode   string `json:"old_mode"`
	NewMode   string `json:"new_mode"`
	OldHash   string `json:"old_hash"`
	NewHash   string `json:"new_hash"`
	Status    string `json:"status"`    // A=added, M=modified, D=deleted, R=renamed, C=copied
	Additions int    `json:"additions"` // Number of lines added
	Deletions int    `json:"deletions"` // Number of lines deleted
}

DiffFile represents a file in a Git diff

func GitRawDiff

func GitRawDiff(repoDir, from, to string) ([]DiffFile, error)

GitRawDiff returns a structured representation of the Git diff between two commits or references If 'to' is empty, it will show unstaged changes (diff with working directory)

type GitLogEntry

type GitLogEntry struct {
	Hash    string   `json:"hash"`    // The full commit hash
	Refs    []string `json:"refs"`    // References (branches, tags) pointing to this commit
	Subject string   `json:"subject"` // The commit subject/message
}

GitLogEntry represents a single entry in the git log

func GitRecentLog

func GitRecentLog(repoDir string, initialCommitHash string) ([]GitLogEntry, error)

GitRecentLog returns the recent commit log between the initial commit and HEAD

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL