Skip to content

Commit

Permalink
Adding support for branches
Browse files Browse the repository at this point in the history
  • Loading branch information
matang28 committed Nov 25, 2019
1 parent ec18220 commit f430a94
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions internal/data/git_remote_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package data
import (
"github.com/securenative/packman/internal/etc"
"gopkg.in/src-d/go-git.v4"
"gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/plumbing/object"
"gopkg.in/src-d/go-git.v4/plumbing/transport"
"gopkg.in/src-d/go-git.v4/plumbing/transport/http"
"os"
"strings"
"time"
)

Expand Down Expand Up @@ -34,10 +36,17 @@ func (this *gitRemoteStorage) getAuth() transport.AuthMethod {

func (this *gitRemoteStorage) Pull(remotePath string, localPath string) error {
etc.PrintInfo("Pulling %s into %s...\n", remotePath, localPath)

remote := strings.Split(remotePath, "@")
if len(remote) == 1 {
remote = append(remote, "master")
}

_, err := git.PlainClone(localPath, false, &git.CloneOptions{
URL: remotePath,
Auth: this.getAuth(),
Progress: os.Stdout,
URL: remote[0],
Auth: this.getAuth(),
Progress: os.Stdout,
ReferenceName: plumbing.NewBranchReferenceName(remote[1]),
})
if err != nil {
return err
Expand Down

0 comments on commit f430a94

Please sign in to comment.