gitcmd

package
v0.0.0-...-4c5dc58 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const REPORT_PATH = "./commit.log"

Variables

View Source
var (

	//git log
	LOG_TPL            = "git -C %s --no-pager log %s --no-merges "
	LOG_FORMAT_TPL     = `--format=format:'%h*-*%an*-*%ct*-*%s' ` //使用*-*作为分隔符
	LOG_AUTHOR_TPL     = `--author=%s `
	LOG_START_DATE_TPL = `--since=%s `
	LOG_END_DATE_TPL   = `--until=%s `
	LOG_RECENTN_TPL    = `-n %d `

	// git show
	SHOW_TPL = "git show %s"

	// git status
	STATUS_TPL = "git -C %s status"

	// git status short
	STATUS_TPL_SHORT = "git -C %s status --short | grep '^[ MADRCU]' | awk '{print $2}'"

	// git status in short result
	STATUS_CHECK_TPL = "git -C %s status -s"

	//git pull
	GIT_PULL = `git -C %s pull --rebase`

	// git clone
	CLONE_TPL = "git clone %s %s"

	// git lab group api
	// gitlab doc  https://docs.gitlab.com/ee/api/groups.html#details-of-a-group
	GITLAB_GROUP_DETAIL = "%s://%s/api/v4/groups%s?private_token=%s"

	// Determine if the current directory is a git repository
	EXIST_GIT_REPO = "git -C %s rev-parse --is-inside-work-tree"

	//git Branch
	GIT_BRANCH = `git branch`

	//git diff
	GIT_DIFF = `git -C %s diff`

	//git add
	GIT_ADD = `git -C %s add .`

	//git commit
	GIT_COMMIT = `git -C %s commit -m "%s"`

	//git push
	GIT_PUSH = `git -C %s push`
)

Functions

func CloneGroup

func CloneGroup(groupUrl, token, targetDir string)

CloneGroup 获取所有项目仓库

func CommitAndPush

func CommitAndPush(dir, cmsg string)

func GetAllGitRepoCommitLog

func GetAllGitRepoCommitLog(detail bool, recentN int16, dir, author, start, end string, branchs bool) (*[]ResultLog, error)

GetAllGitRepoCommitLog 封装所有仓库的提交信息

func GetAllGitRepoStatus

func GetAllGitRepoStatus(dir string)

GetAllGitRepoStatus 查看所有仓库的状态

func GetChangedFile

func GetChangedFile(commitId string) ([]string, error)

GetChangedFile 获取本次提交变动的文件名

func GetCommitLog

func GetCommitLog(detail bool, recentN int16, dir, author, start, end string, branchs bool) (*[]CommitLog, error)

GetCommitLog 获取提交日志

func GetGitCommitMsg

func GetGitCommitMsg(dir string) string

GetGitCommitMsg git commit msg from ai

func GitLogSummary

func GitLogSummary(detail bool, dir, committer, start, end string)

GitLogSummary summary commit log

func ListRepoAllBranch

func ListRepoAllBranch(repo string) (re *branchInfo)

ListRepoAllBranch list all git Branch under repository

func UpdateAllGitRepo

func UpdateAllGitRepo(dir string)

UpdateAllGitRepo 更新所有仓库

Types

type CommitData

type CommitData struct {
	CommitMsg      []CommitMsg `json:"commitMsg"` // List of commit messages
	OptionalBody   string      `json:"optionalBody"`
	OptionalFooter string      `json:"optionalFooter"`
}

type CommitLog

type CommitLog struct {
	Branch       string   //Branch
	CommitHash   string   //abbreviated commit hash
	Username     string   //username
	CommitAt     string   //commit time
	CommitMsg    string   //commit log
	FilesChanged []string //changed file arr
}

CommitLog 提交记录

type CommitMsg

type CommitMsg struct {
	Type        string `json:"type"`        // Type of the commit, e.g., feat, fix, docs, etc.
	Scope       string `json:"scope"`       // Scope of the impact (optional)
	Description string `json:"description"` // Brief description of the commit
}

type ConsoleOutput

type ConsoleOutput struct {
}

func (*ConsoleOutput) Output

func (c *ConsoleOutput) Output(resLogs *[]ResultLog)

type FileOutput

type FileOutput struct {
}

func (*FileOutput) Output

func (c *FileOutput) Output(resLogs *[]ResultLog)

type GitSummaryPromptResp

type GitSummaryPromptResp struct {
	RepoSummary []RepoSummary `json:"repo_summary"`
}

type OutputFormatter

type OutputFormatter interface {
	Output(*[]ResultLog)
}

type ProjectInfo

type ProjectInfo struct {
	HttpUrlToRepo string
	Path          string
}

type RepoSummary

type RepoSummary struct {
	Repo      string   `json:"repo"`
	Summary   []string `json:"summary"`
	SummaryCN []string `json:"summary_cn"`
}

type ResultLog

type ResultLog struct {
	RepoName   string //git repository name
	CommitLogs *[]CommitLog
}

ResultLog 封装日志分析结果

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳