Skip to content

Commit f26dd37

Browse files
author
Casey Hillers
authored
[packaging] Run git gc to minimize .git disk footprint (#113467)
1 parent bc70ae0 commit f26dd37

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

dev/bots/prepare_package.dart

+3
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,9 @@ class ArchiveCreator {
418418

419419
// Make the origin point to github instead of the chromium mirror.
420420
await _runGit(<String>['remote', 'set-url', 'origin', githubRepo]);
421+
422+
// Minify `.git` footprint (saving about ~100 MB as of Oct 2022)
423+
await _runGit(<String>['gc', '--prune=now', '--aggressive']);
421424
}
422425

423426
/// Retrieve the MinGit executable from storage and unpack it.

dev/bots/test/prepare_package_test.dart

+5
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ void main() {
126126
'git clone -b beta https://flutter.googlesource.com/mirrors/flutter': null,
127127
'git reset --hard $testRef': null,
128128
'git remote set-url origin https://github.com/flutter/flutter.git': null,
129+
'git gc --prune=now --aggressive': null,
129130
'git describe --tags --exact-match $testRef': <ProcessResult>[ProcessResult(0, 0, 'v1.2.3', '')],
130131
'$flutter --version --machine': <ProcessResult>[
131132
ProcessResult(0, 0, '{"dartSdkVersion": "3.2.1"}', ''),
@@ -162,6 +163,7 @@ void main() {
162163
'git clone -b beta https://flutter.googlesource.com/mirrors/flutter': null,
163164
'git reset --hard $testRef': null,
164165
'git remote set-url origin https://github.com/flutter/flutter.git': null,
166+
'git gc --prune=now --aggressive': null,
165167
'git describe --tags --exact-match $testRef': <ProcessResult>[ProcessResult(0, 0, 'v1.2.3', '')],
166168
'$flutter --version --machine': <ProcessResult>[
167169
ProcessResult(0, 0, '{"dartSdkVersion": "3.2.1"}', ''),
@@ -209,6 +211,7 @@ void main() {
209211
'git clone -b beta https://flutter.googlesource.com/mirrors/flutter': null,
210212
'git reset --hard $testRef': null,
211213
'git remote set-url origin https://github.com/flutter/flutter.git': null,
214+
'git gc --prune=now --aggressive': null,
212215
'git describe --tags --exact-match $testRef': <ProcessResult>[ProcessResult(0, 0, 'v1.2.3', '')],
213216
'$flutter --version --machine': <ProcessResult>[
214217
ProcessResult(0, 0, '{"dartSdkVersion": "3.2.1"}', ''),
@@ -266,6 +269,7 @@ void main() {
266269
'git clone -b beta https://flutter.googlesource.com/mirrors/flutter': null,
267270
'git reset --hard $testRef': null,
268271
'git remote set-url origin https://github.com/flutter/flutter.git': null,
272+
'git gc --prune=now --aggressive': null,
269273
'git describe --tags --abbrev=0 $testRef': <ProcessResult>[ProcessResult(0, 0, 'v1.2.3', '')],
270274
'$flutter --version --machine': <ProcessResult>[
271275
ProcessResult(0, 0, '{"dartSdkVersion": "3.2.1"}', ''),
@@ -315,6 +319,7 @@ void main() {
315319
'git clone -b beta https://flutter.googlesource.com/mirrors/flutter': null,
316320
'git reset --hard $testRef': null,
317321
'git remote set-url origin https://github.com/flutter/flutter.git': null,
322+
'git gc --prune=now --aggressive': null,
318323
'git describe --tags --exact-match $testRef': <ProcessResult>[ProcessResult(0, 0, 'v1.2.3', '')],
319324
'$flutter --version --machine': <ProcessResult>[
320325
ProcessResult(0, 0, '{"dartSdkVersion": "3.2.1"}', ''),

0 commit comments

Comments
 (0)