Skip to content

Commit

Permalink
pull default branch
Browse files Browse the repository at this point in the history
  • Loading branch information
xxf098 committed Nov 30, 2022
1 parent 2641f6b commit cf06e49
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
uses: actions/checkout@v3
- name: Pre
run: |
wget -q https://github.com/xxf098/actionflow/releases/download/v0.5.8/flow-linux-amd64-v0.5.8.zip
unzip flow-linux-amd64-v0.5.8.zip
wget -q https://github.com/xxf098/actionflow/releases/download/v0.5.9/flow-linux-amd64-v0.5.9.zip
unzip flow-linux-amd64-v0.5.9.zip
rm -rf cue.mod
./flow init && ./flow update
./flow do setup
Expand Down
25 changes: 17 additions & 8 deletions common/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,27 @@ func Clone(ctx context.Context, input GitCloneConfig) error {
}

// fetch latest changes
fetchOptions, pullOptions := gitOptions(input.Token)
_, pullOptions := gitOptions(input.Token)

err = r.Fetch(&fetchOptions)
if err != nil && !errors.Is(err, git.NoErrAlreadyUpToDate) {
// err = r.Fetch(&fetchOptions)
// if err != nil && !errors.Is(err, git.NoErrAlreadyUpToDate) {
// return err
// }

var w *git.Worktree
if w, err = r.Worktree(); err != nil {
return err
}

if len(input.Ref) < 1 {
if err = w.Pull(&pullOptions); err != nil && err != git.NoErrAlreadyUpToDate {
logger.Debugf("Unable to pull %s: %v", refName, err)
return err
}
logger.Debugf("Cloned %s to %s", input.URL, input.Dir)
return nil
}

var hash *plumbing.Hash
rev := plumbing.Revision(input.Ref)
if hash, err = r.ResolveRevision(rev); err != nil {
Expand Down Expand Up @@ -363,11 +377,6 @@ func Clone(ctx context.Context, input GitCloneConfig) error {
return err
}

var w *git.Worktree
if w, err = r.Worktree(); err != nil {
return err
}

// If the hash resolved doesn't match the ref provided in a workflow then we're
// using a branch or tag ref, not a sha
//
Expand Down
4 changes: 2 additions & 2 deletions do_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ func TestGitPull(t *testing.T) {
doTest("./testcues/git.cue", "hello")
}

func TestCheckout(t *testing.T) {
doTest("./testcues/git.cue", "checkout")
func TestGitCheckout(t *testing.T) {
doTest("./testcues/git.cue", "lite")
}

func TestWorkDir(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/github.com/xxf098/actionflow/core/git.cue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package core
$dagger: task: _name: "Git"
args: [...string] | *[]
repo: string | *""
ref: string | *"HEAD"
ref: string | *""
dir: string | *""
token: string | *""
}

0 comments on commit cf06e49

Please sign in to comment.