Skip to content

Commit

Permalink
Merge pull request #2245 from git-lfs/release-2.1-backport-2237
Browse files Browse the repository at this point in the history
Backport #2237 for v2.1.x: Make pull return non-zero error code when some downloads failed
  • Loading branch information
ttaylorr committed May 19, 2017
2 parents af1ccad + e5679f3 commit ce97ff4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
4 changes: 3 additions & 1 deletion commands/command_fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ func fetchCommand(cmd *cobra.Command, args []string) {
}

if !success {
Exit("Warning: errors occurred")
c := getAPIClient()
e := c.Endpoints.Endpoint("download", cfg.CurrentRemote)
Exit("error: failed to push some objects to '%s'", e.Url)
}
}

Expand Down
8 changes: 8 additions & 0 deletions commands/command_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,17 @@ func pull(remote string, filter *filepathfilter.Filter) {

singleCheckout.Close()

success := true
for _, err := range q.Errors() {
success = false
FullError(err)
}

if !success {
c := getAPIClient()
e := c.Endpoints.Endpoint("download", remote)
Exit("error: failed to push some objects to '%s'", e.Url)
}
}

// tracks LFS objects being downloaded, according to their unique OIDs.
Expand Down
27 changes: 26 additions & 1 deletion test/test-pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ begin_test "pull"
setup_remote_repo "$reponame"

clone_repo "$reponame" clone

clone_repo "$reponame" repo

git lfs track "*.dat" 2>&1 | tee track.log
Expand Down Expand Up @@ -139,6 +138,32 @@ begin_test "pull with raw remote url"
)
end_test

begin_test "pull: with missing object"
(
set -e

# this clone is setup in the first test in this file
cd clone
rm -rf .git/lfs/objects

contents_oid=$(calc_oid "a")
reponame="$(basename "$0" ".sh")"
delete_server_object "$reponame" "$contents_oid"
refute_server_object "$reponame" "$contents_oid"

# should return non-zero, but should also download all the other valid files too
git lfs pull 2>&1 | tee pull.log
pull_exit="${PIPESTATUS[0]}"
[ "$pull_exit" != "0" ]

grep "$contents_oid" pull.log

contents2_oid=$(calc_oid "A")
assert_local_object "$contents2_oid" 1
refute_local_object "$contents_oid"
)
end_test

begin_test "pull: outside git repository"
(
set +e
Expand Down

0 comments on commit ce97ff4

Please sign in to comment.