Skip to content

Commit

Permalink
Merge pull request #186 from spire-allyjweir/add-git-lfs-support
Browse files Browse the repository at this point in the history
Add git-lfs support
  • Loading branch information
rickardl authored Oct 20, 2020
2 parents e371a05 + fae4c1d commit a506a61
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ FROM alpine:3.11 as resource
COPY --from=builder /go/src/github.com/telia-oss/github-pr-resource/build /opt/resource
RUN apk add --update --no-cache \
git \
git-lfs \
openssh \
&& chmod +x /opt/resource/*
COPY scripts/askpass.sh /usr/local/bin/askpass.sh
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Make sure to check out [#migrating](#migrating) to learn more.
| `git_crypt_key` | No | `AEdJVENSWVBUS0VZAAAAA...` | Base64 encoded git-crypt key. Setting this will unlock / decrypt the repository with git-crypt. To get the key simply execute `git-crypt export-key -- - | base64` in an encrypted repository. |
| `base_branch` | No | `master` | Name of a branch. The pipeline will only trigger on pull requests against the specified branch. |
| `labels` | No | `["bug", "enhancement"]` | The labels on the PR. The pipeline will only trigger on pull requests having at least one of the specified labels. |
| `disable_git_lfs` | No | `true` | Disable Git LFS, skipping an attempt to convert pointers of files tracked into their corresponding objects when checked out into a working copy. |

Notes:
- If `v3_endpoint` is set, `v4_endpoint` must also be set (and the other way around).
Expand Down
9 changes: 8 additions & 1 deletion git.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ func NewGitClient(source *Source, dir string, output io.Writer) (*GitClient, err
if source.SkipSSLVerification {
os.Setenv("GIT_SSL_NO_VERIFY", "true")
}
if source.DisableGitLFS {
os.Setenv("GIT_LFS_SKIP_SMUDGE", "true")
}
return &GitClient{
AccessToken: source.AccessToken,
Directory: dir,
Expand Down Expand Up @@ -87,7 +90,11 @@ func (g *GitClient) Pull(uri, branch string, depth int, submodules bool, fetchTa
return err
}

args := []string{"pull", endpoint + ".git", branch}
if err := g.command("git", "remote", "add", "origin", endpoint).Run(); err != nil {
return fmt.Errorf("setting 'origin' remote to '%s' failed: %s", endpoint, err)
}

args := []string{"pull", "origin", branch}
if depth > 0 {
args = append(args, "--depth", strconv.Itoa(depth))
}
Expand Down
1 change: 1 addition & 0 deletions models.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Source struct {
Paths []string `json:"paths"`
IgnorePaths []string `json:"ignore_paths"`
DisableCISkip bool `json:"disable_ci_skip"`
DisableGitLFS bool `json:"disable_git_lfs"`
SkipSSLVerification bool `json:"skip_ssl_verification"`
DisableForks bool `json:"disable_forks"`
GitCryptKey string `json:"git_crypt_key"`
Expand Down

0 comments on commit a506a61

Please sign in to comment.