replace go-git dependancy with plain git
This commit is contained in:
parent
4ac4f3e84d
commit
cd50e0fe26
85
git/clone.go
85
git/clone.go
|
@ -4,10 +4,9 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/config"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
"github.com/badjware/gitlabfs/utils"
|
||||
)
|
||||
|
||||
type gitCloneParam struct {
|
||||
|
@ -29,7 +28,7 @@ func (c *gitClient) cloneWorker() {
|
|||
}
|
||||
|
||||
func (c *gitClient) clone(gcp *gitCloneParam) error {
|
||||
branchRef := plumbing.NewBranchReferenceName(gcp.defaultBranch)
|
||||
// branchRef := plumbing.NewBranchReferenceName(gcp.defaultBranch)
|
||||
|
||||
if c.Clone {
|
||||
// Clone the repo
|
||||
|
@ -37,13 +36,21 @@ func (c *gitClient) clone(gcp *gitCloneParam) error {
|
|||
fmt.Printf("Cloning %v into %v\n", gcp.url, gcp.dst)
|
||||
// fs := osfs.New(gcp.dst)
|
||||
// storer := filesystem.NewStorage(fs, cache.NewObjectLRU(0))
|
||||
_, err := git.PlainClone(gcp.dst, false, &git.CloneOptions{
|
||||
URL: gcp.url,
|
||||
RemoteName: c.RemoteName,
|
||||
ReferenceName: branchRef,
|
||||
NoCheckout: !c.Checkout,
|
||||
Depth: c.PullDepth,
|
||||
})
|
||||
// _, err := git.PlainClone(gcp.dst, false, &git.CloneOptions{
|
||||
// URL: gcp.url,
|
||||
// RemoteName: c.RemoteName,
|
||||
// ReferenceName: branchRef,
|
||||
// NoCheckout: !c.Checkout,
|
||||
// Depth: c.PullDepth,
|
||||
// })
|
||||
_, err := utils.ExecProcess(
|
||||
"git", "clone",
|
||||
"--origin", c.RemoteName,
|
||||
"--depth", strconv.Itoa(c.PullDepth),
|
||||
"--",
|
||||
gcp.url, // repository
|
||||
gcp.dst, // directory
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to clone git repo %v to %v: %v", gcp.url, gcp.dst, err)
|
||||
}
|
||||
|
@ -53,38 +60,52 @@ func (c *gitClient) clone(gcp *gitCloneParam) error {
|
|||
// We can save a lot of time and network i/o doing it this way, at the cost of
|
||||
// resulting in a very barebone local copy
|
||||
fmt.Printf("Initializing %v into %v\n", gcp.url, gcp.dst)
|
||||
r, err := git.PlainInit(gcp.dst, false)
|
||||
// r, err := git.PlainInit(gcp.dst, false)
|
||||
_, err := utils.ExecProcess(
|
||||
"git", "init",
|
||||
"--initial-branch", gcp.defaultBranch,
|
||||
"--",
|
||||
gcp.dst, // directory
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to clone git repo %v to %v: %v", gcp.url, gcp.dst, err)
|
||||
return fmt.Errorf("failed to init git repo %v to %v: %v", gcp.url, gcp.dst, err)
|
||||
}
|
||||
|
||||
// Configure the remote
|
||||
_, err = r.CreateRemote(&config.RemoteConfig{
|
||||
Name: c.RemoteName,
|
||||
URLs: []string{gcp.url},
|
||||
})
|
||||
// _, err = r.CreateRemote(&config.RemoteConfig{
|
||||
// Name: c.RemoteName,
|
||||
// URLs: []string{gcp.url},
|
||||
// })
|
||||
_, err = utils.ExecProcessInDir(
|
||||
gcp.dst, // workdir
|
||||
"git", "remote", "add",
|
||||
"-t", gcp.defaultBranch,
|
||||
"--",
|
||||
c.RemoteName, // name
|
||||
gcp.url, // url
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to setup remote %v in git repo %v: %v", gcp.url, gcp.dst, err)
|
||||
}
|
||||
|
||||
// Configure a local branch to track the remote branch
|
||||
err = r.CreateBranch(&config.Branch{
|
||||
Name: gcp.defaultBranch,
|
||||
Remote: c.RemoteName,
|
||||
Merge: plumbing.ReferenceName(fmt.Sprintf("refs/heads/%s", gcp.defaultBranch)),
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create branch %v of git repo %v: %v", gcp.defaultBranch, gcp.dst, err)
|
||||
}
|
||||
// err = r.CreateBranch(&config.Branch{
|
||||
// Name: gcp.defaultBranch,
|
||||
// Remote: c.RemoteName,
|
||||
// Merge: plumbing.ReferenceName(fmt.Sprintf("refs/heads/%s", gcp.defaultBranch)),
|
||||
// })
|
||||
// if err != nil {
|
||||
// return fmt.Errorf("failed to create branch %v of git repo %v: %v", gcp.defaultBranch, gcp.dst, err)
|
||||
// }
|
||||
|
||||
// Checkout the default branch
|
||||
w, err := r.Worktree()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to retrieve worktree of git repo %v: %v", gcp.dst, err)
|
||||
}
|
||||
w.Checkout(&git.CheckoutOptions{
|
||||
Branch: branchRef,
|
||||
})
|
||||
// w, err := r.Worktree()
|
||||
// if err != nil {
|
||||
// return fmt.Errorf("failed to retrieve worktree of git repo %v: %v", gcp.dst, err)
|
||||
// }
|
||||
// w.Checkout(&git.CheckoutOptions{
|
||||
// Branch: branchRef,
|
||||
// })
|
||||
}
|
||||
if c.PullAfterClone {
|
||||
// Dispatch to pull worker
|
||||
|
|
59
git/pull.go
59
git/pull.go
|
@ -2,9 +2,9 @@ package git
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
"github.com/badjware/gitlabfs/utils"
|
||||
)
|
||||
|
||||
type gitPullParam struct {
|
||||
|
@ -23,37 +23,40 @@ func (c *gitClient) pullWorker() {
|
|||
}
|
||||
|
||||
func (c *gitClient) pull(gpp *gitPullParam) error {
|
||||
r, err := git.PlainOpen(gpp.repoPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to open git repo %v: %v", gpp.repoPath, err)
|
||||
}
|
||||
w, err := r.Worktree()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to retrieve worktree of git repo %v: %v", gpp.repoPath, err)
|
||||
}
|
||||
// r, err := git.PlainOpen(gpp.repoPath)
|
||||
// if err != nil {
|
||||
// return fmt.Errorf("failed to open git repo %v: %v", gpp.repoPath, err)
|
||||
// }
|
||||
// w, err := r.Worktree()
|
||||
// if err != nil {
|
||||
// return fmt.Errorf("failed to retrieve worktree of git repo %v: %v", gpp.repoPath, err)
|
||||
// }
|
||||
|
||||
// Check if the local repo is on default branch
|
||||
headRef, err := r.Head()
|
||||
// headRef, err := r.Head()
|
||||
branchName, err := utils.ExecProcessInDir(
|
||||
gpp.repoPath, // workdir
|
||||
"git", "branch",
|
||||
"--show-current",
|
||||
)
|
||||
if err != nil {
|
||||
// We ignore "reference not found" as this occurs when the local branch
|
||||
// has never been checked out when we are in init-pull mode
|
||||
if err.Error() != "reference not found" {
|
||||
return fmt.Errorf("failed to retrieve HEAD of git repo %v: %v", gpp.repoPath, err)
|
||||
}
|
||||
} else {
|
||||
branchRef := plumbing.ReferenceName(fmt.Sprintf("refs/heads/%s", gpp.defaultBranch))
|
||||
if headRef.Name() != branchRef {
|
||||
// default branch is not checked out, nothing to do
|
||||
fmt.Printf("Repo %v is not on default branch (%v != %v), skipping pull\n", gpp.repoPath, branchRef, headRef.Name())
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("failed to retrieve HEAD of git repo %v: %v", gpp.repoPath, err)
|
||||
}
|
||||
|
||||
// Pull the remote
|
||||
// TODO: Just like clone, this is very memory intensive for some reasons...
|
||||
fmt.Printf("Pulling %v\n", gpp.repoPath)
|
||||
if err := w.Pull(&git.PullOptions{RemoteName: c.RemoteName, Depth: c.PullDepth}); err != nil {
|
||||
return fmt.Errorf("failed to pull git repo %v: %v", gpp.repoPath, err)
|
||||
if branchName == gpp.defaultBranch {
|
||||
_, err = utils.ExecProcessInDir(
|
||||
gpp.repoPath, // workdir
|
||||
"git", "pull",
|
||||
"--depth", strconv.Itoa(c.PullDepth),
|
||||
"--",
|
||||
c.RemoteName, // repository
|
||||
gpp.defaultBranch, // refspec
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to pull git repo %v: %v", gpp.repoPath, err)
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("%v != %v, skipping pull", branchName, gpp.defaultBranch)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
7
go.mod
7
go.mod
|
@ -3,10 +3,7 @@ module github.com/badjware/gitlabfs
|
|||
go 1.15
|
||||
|
||||
require (
|
||||
github.com/go-git/go-billy/v5 v5.0.0
|
||||
github.com/go-git/go-git/v5 v5.2.0
|
||||
github.com/hanwen/go-fuse v1.0.0
|
||||
github.com/hanwen/go-fuse/v2 v2.0.3
|
||||
github.com/xanzy/go-gitlab v0.40.2
|
||||
gopkg.in/yaml.v2 v2.2.4
|
||||
github.com/xanzy/go-gitlab v0.44.0
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
)
|
||||
|
|
72
go.sum
72
go.sum
|
@ -1,22 +1,8 @@
|
|||
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
|
||||
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
|
||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
|
||||
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
|
||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
||||
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
|
||||
github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4=
|
||||
github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E=
|
||||
github.com/go-git/go-billy/v5 v5.0.0 h1:7NQHvd9FVid8VL4qVUMm8XifBK+2xCoZ2lSk0agRrHM=
|
||||
github.com/go-git/go-billy/v5 v5.0.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
|
||||
github.com/go-git/go-git-fixtures/v4 v4.0.2-0.20200613231340-f56387b50c12/go.mod h1:m+ICp2rF3jDhFgEZ/8yziagdT1C+ZpZcrJjappBCDSw=
|
||||
github.com/go-git/go-git/v5 v5.2.0 h1:YPBLG/3UK1we1ohRkncLjaXWLW+HKp5QNM/jTli2JgI=
|
||||
github.com/go-git/go-git/v5 v5.2.0/go.mod h1:kh02eMX+wdqqxgNMEyq8YgwlIOsDOa9homkUq1PoTMs=
|
||||
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
|
||||
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
||||
github.com/hanwen/go-fuse v1.0.0 h1:GxS9Zrn6c35/BnfiVsZVWmsG803xwE7eVRDvcf/BEVc=
|
||||
|
@ -25,64 +11,36 @@ github.com/hanwen/go-fuse/v2 v2.0.3 h1:kpV28BKeSyVgZREItBLnaVBvOEwv2PuhNdKetwnvN
|
|||
github.com/hanwen/go-fuse/v2 v2.0.3/go.mod h1:0EQM6aH2ctVpvZ6a+onrQ/vaykxh2GH7hy3e13vzTUY=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
|
||||
github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI=
|
||||
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
|
||||
github.com/hashicorp/go-retryablehttp v0.6.4 h1:BbgctKO892xEyOXnGiaAwIoSq1QZ/SS4AhjoAh9DnfY=
|
||||
github.com/hashicorp/go-retryablehttp v0.6.4/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
|
||||
github.com/imdario/mergo v0.3.9 h1:UauaLniWCFHWd+Jp9oCEkTBj8VO/9DKg3PV3VCNMDIg=
|
||||
github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
|
||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
|
||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY=
|
||||
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4=
|
||||
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
|
||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
|
||||
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/xanzy/go-gitlab v0.40.2 h1:XSMIrvcv+7/zK2NPX7Xsa8wC9Qb5vbLfeQ723v4S+qA=
|
||||
github.com/xanzy/go-gitlab v0.40.2/go.mod h1:sPLojNBn68fMUWSxIJtdVVIP8uSBYqesTfDUseX11Ug=
|
||||
github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=
|
||||
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
|
||||
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073 h1:xMPOj6Pz6UipU1wXLkrtqpHbR0AVFnyPEQq/wRWz9lM=
|
||||
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
github.com/xanzy/go-gitlab v0.44.0 h1:cEiGhqu7EpFGuei2a2etAwB+x6403E5CvpLn35y+GPs=
|
||||
github.com/xanzy/go-gitlab v0.44.0/go.mod h1:sPLojNBn68fMUWSxIJtdVVIP8uSBYqesTfDUseX11Ug=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181108082009-03003ca0c849 h1:FSqE2GGG7wzsYUsWiQ8MZrvEd1EOyU3NCF0AW3Wtltg=
|
||||
golang.org/x/net v0.0.0-20181108082009-03003ca0c849/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a h1:GuSPYbZzB5/dcLNCwLQLsg3obCJtX9IJhpXkvY7kzk0=
|
||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288 h1:JIqe8uIcRBHXDQVvZtHwp80ai3Lw3IJAeJEs55Dc1W0=
|
||||
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTmV7VDcZyvRZ+QQXkXTZQ=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522 h1:Ve1ORMCxvRmSXBwJK+t3Oy+V2vRW2OetUQBq4rJIkZE=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 h1:uYVVQ9WP/Ds2ROhcaGPeIdVq0RIXVLwsHlnvJ+cT1So=
|
||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
google.golang.org/appengine v1.3.0 h1:FBSsiFRMz3LBeXIomRnVzrQwSDj4ibvcRexLG0LZGQk=
|
||||
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
|
||||
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
stdout = "stdout"
|
||||
stderr = "stderr"
|
||||
)
|
||||
|
||||
func ExecProcessInDir(workdir string, command string, args ...string) (string, error) {
|
||||
cmd := exec.Command(command, args...)
|
||||
if workdir != "" {
|
||||
cmd.Dir = workdir
|
||||
}
|
||||
|
||||
// Run the command
|
||||
fmt.Printf("%v %v\n", command, strings.Join(args, " "))
|
||||
output, err := cmd.Output()
|
||||
|
||||
return strings.TrimSpace(string(output)), err
|
||||
}
|
||||
|
||||
func ExecProcess(command string, args ...string) (string, error) {
|
||||
return ExecProcessInDir("", command, args...)
|
||||
}
|
Loading…
Reference in New Issue