func()

in pkg/client/git/client.go [128:154]


func (c *Client) Commit(projectName, message string, files []string, user *User) error {
	projectPath := c.projectPath(projectName)

	r, err := git.PlainOpen(projectPath)
	if err != nil {
		return errors.Wrap(err, "unable to open repository")
	}

	w, err := r.Worktree()
	if err != nil {
		return errors.Wrap(err, "unable to get repo worktree")
	}

	for _, f := range files {
		if _, err := w.Add(f); err != nil {
			return errors.Wrapf(err, "unable to add file: %s", f)
		}
	}

	if _, err := w.Commit(message, &git.CommitOptions{
		Author: &object.Signature{Name: user.Name, Email: user.Email, When: time.Now()},
	}); err != nil {
		return errors.Wrap(err, "unable to perform git commit")
	}

	return nil
}