git

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Git

type Git struct {
	// contains filtered or unexported fields
}

Git 封装 go-git go-git 是 git 的子集,很多功能并不支持,查看不同:https://github.com/go-git/go-git/blob/master/COMPATIBILITY.md 比如 pull 只支持 fast-forward,不支持 stash,所以在封装的时候回做一些取舍: merge 与 解决冲突是十分复杂的操作,hollow 无法实现它们,所以在同步的时候采取以下策略:

  • pull 时 如果传递 force=true,如果遇到 non-fast-forward,则会将远端文件全部下载下来,cp 到本地,相同文件保留最新的一个。尽量将降低影响。
  • push:为了避免 push 的冲突,每次 push 都是 force 的,为了避免远端文件丢失,每次 push 之前都会 pull 一次。

non-fast-forward: 当本地有提交,pull 都会报错 non-fast-forward。

func NewGit

func NewGit(personalAccessTokens string, dir billy.Filesystem, log *zap.SugaredLogger) (g *Git, err error)

NewGit return Git https://docs.github.com/cn/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token

func (*Git) Pull

func (g *Git) Pull(remote string, branch string, force bool) error

Jump to

Keyboard shortcuts

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