Skip to content

Commit

Permalink
Use --prune for all git fetch operations
Browse files Browse the repository at this point in the history
In environments with long lived git checkouts git fetch operations can
fail after time, due to rebasing operations or other reasons with
messages like:

```
There are too many unreachable loose objects; run 'git prune' to
remove them.
```

Ensure `git fetch` always uses the --prune flag.

Relates #650
  • Loading branch information
dliappis authored Feb 20, 2019
1 parent 317d833 commit 99e90d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions esrally/utils/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ def pull(src_dir, remote="origin", branch="master"):
@probed
def pull_ts(src_dir, ts):
if process.run_subprocess(
"git -C {0} fetch --quiet origin && git -C {0} checkout --quiet `git -C {0} rev-list -n 1 --before=\"{1}\" "
"git -C {0} fetch --prune --quiet origin && git -C {0} checkout --quiet `git -C {0} rev-list -n 1 --before=\"{1}\" "
"--date=iso8601 origin/master`".format(src_dir, ts)):
raise exceptions.SupplyError("Could not fetch source tree for timestamped revision [%s]" % ts)


@probed
def pull_revision(src_dir, revision):
if process.run_subprocess(
"git -C {0} fetch --quiet origin && git -C {0} checkout --quiet {1}".format(src_dir, revision)):
"git -C {0} fetch --prune --quiet origin && git -C {0} checkout --quiet {1}".format(src_dir, revision)):
raise exceptions.SupplyError("Could not fetch source tree for revision [%s]" % revision)


Expand Down
4 changes: 2 additions & 2 deletions tests/utils/git_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def test_pull_ts(self, run_subprocess_with_logging, run_subprocess):
run_subprocess.return_value = False
git.pull_ts("/src", "20160101T110000Z")
run_subprocess.assert_called_with(
"git -C /src fetch --quiet origin && git -C /src checkout "
"git -C /src fetch --prune --quiet origin && git -C /src checkout "
"--quiet `git -C /src rev-list -n 1 --before=\"20160101T110000Z\" --date=iso8601 origin/master`")

@mock.patch("esrally.utils.process.run_subprocess")
Expand All @@ -146,7 +146,7 @@ def test_pull_revision(self, run_subprocess_with_logging, run_subprocess):
run_subprocess_with_logging.return_value = 0
run_subprocess.return_value = False
git.pull_revision("/src", "3694a07")
run_subprocess.assert_called_with("git -C /src fetch --quiet origin && git -C /src checkout --quiet 3694a07")
run_subprocess.assert_called_with("git -C /src fetch --prune --quiet origin && git -C /src checkout --quiet 3694a07")

@mock.patch("esrally.utils.process.run_subprocess_with_output")
@mock.patch("esrally.utils.process.run_subprocess_with_logging")
Expand Down

0 comments on commit 99e90d1

Please sign in to comment.