mirror of
https://github.com/fluxcd/flux2.git
synced 2026-02-22 07:31:47 +00:00
Add add command to git
Signed-off-by: Philip Laine <philip.laine@gmail.com>
This commit is contained in:
parent
d3629898ea
commit
5691a444f1
2 changed files with 13 additions and 0 deletions
|
|
@ -44,6 +44,7 @@ type Git interface {
|
|||
Init(url, branch string) (bool, error)
|
||||
Clone(ctx context.Context, url, branch string, caBundle []byte) (bool, error)
|
||||
Write(path string, reader io.Reader) error
|
||||
Add(path string) error
|
||||
Commit(message Commit, options ...Option) (string, error)
|
||||
Push(ctx context.Context, caBundle []byte) error
|
||||
Status() (bool, error)
|
||||
|
|
|
|||
|
|
@ -89,6 +89,18 @@ func (g *GoGit) Init(url, branch string) (bool, error) {
|
|||
return true, nil
|
||||
}
|
||||
|
||||
func (g *GoGit) Add(path string) error {
|
||||
wt, err := g.repository.Worktree()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = wt.Add(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *GoGit) Clone(ctx context.Context, url, branch string, caBundle []byte) (bool, error) {
|
||||
branchRef := plumbing.NewBranchReferenceName(branch)
|
||||
r, err := gogit.PlainCloneContext(ctx, g.path, false, &gogit.CloneOptions{
|
||||
|
|
|
|||
Loading…
Reference in a new issue