mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 13:37:08 +08:00
git: update gitutil test utilities
- Adds a new GitServeHTTP function to start an http server to serve a target git repository. - Adds a new GitDir helper method to get the path to the .git directory - Updates the GitAdd method to take a variable number of files Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
@ -6,6 +6,7 @@ import (
|
||||
"net/url"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@ -68,6 +69,14 @@ func (c *Git) RootDir() (string, error) {
|
||||
return c.clean(c.run("rev-parse", "--show-toplevel"))
|
||||
}
|
||||
|
||||
func (c *Git) GitDir() (string, error) {
|
||||
dir, err := c.RootDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return filepath.Join(dir, ".git"), nil
|
||||
}
|
||||
|
||||
func (c *Git) RemoteURL() (string, error) {
|
||||
// Try to get the remote URL from the origin remote first
|
||||
if ru, err := c.clean(c.run("remote", "get-url", "origin")); err == nil && ru != "" {
|
||||
|
Reference in New Issue
Block a user