Skip to content

Commit 88a6a8f

Browse files
committed
Clone only the tag needed to generate the docs
Before, for each released version, we were cloning the entire Rails repository in a new directory, then checking out the tag we wanted. This is inefficient in both time and space. Our server is full of copies of the Rails repository, one per released version, and each copy contains the full history of the repository, using gigabytes of disk space. To save in both time and space, we can clone only the specific tag we need, using git's `--branch` and `--depth 1` options.
1 parent f905dbe commit 88a6a8f

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

lib/git_manager.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ def update_main
3939
def checkout(tag)
4040
Dir.chdir(basedir) do
4141
log "checking out tag #{tag}"
42-
log_and_system "git clone -q #{remote_rails_url} #{tag}"
43-
44-
Dir.chdir(tag) do
45-
log_and_system "git checkout -q #{tag}"
46-
end
42+
log_and_system "git -c advice.detachedHead=false clone -q --depth 1 --single-branch --branch #{tag} #{remote_rails_url} #{tag}"
4743
end
4844
end
4945

0 commit comments

Comments
 (0)