Skip to content

Commit

Permalink
Merge pull request #363 from brave/cachedir
Browse files Browse the repository at this point in the history
add optional cache for cloning repos
  • Loading branch information
bbondy authored Jun 25, 2018
2 parents c1fc1ac + 6c2176e commit 437d50e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const Config = function () {
this.defaultGClientFile = path.join(this.rootDir, '.gclient')
this.gClientFile = process.env.BRAVE_GCLIENT_FILE || this.defaultGClientFile
this.gClientVerbose = getNPMConfig(['gclient_verbose']) || false
this.gClientCacheDir = getNPMConfig(['gclient_cachedir']) || false
this.targetArch = 'x64'
this.gypTargetArch = 'x64'
this.officialBuild = true
Expand Down Expand Up @@ -251,6 +252,9 @@ Config.prototype.update = function (options) {
if (options.gclient_verbose)
this.gClientVerbose = options.gclient_verbose

if (options.gclient_cachedir)
this.gClientCacheDir = options.gclient_cachedir

this.projectNames.forEach((projectName) => {
// don't update refs for projects that have them
let project = this.projects[projectName]
Expand Down
7 changes: 5 additions & 2 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const fs = require('fs-extra')

const runGClient = (args, options = {}) => {
if (config.gClientVerbose) args.push('--verbose')
if (config.gClientCacheDir) args.push('--cache-dir=' + config.gClientCacheDir)
options.cwd = options.cwd || config.rootDir
options = mergeWithDefault(options)
options.env.GCLIENT_FILE = config.gClientFile
Expand Down Expand Up @@ -47,7 +48,9 @@ const util = {
}
})

const out = 'solutions = ' + JSON.stringify(solutions, replacer, 2)
let out = ''
if (config.gClientCacheDir) cache_dir_line = 'cache_dir = "' + config.gClientCacheDir + '"\n'
out += 'solutions = ' + JSON.stringify(solutions, replacer, 2)
.replace(/"%None%"/g, "None")
.replace(/"%False%"/g, "False")
fs.writeFileSync(config.defaultGClientFile, out)
Expand Down Expand Up @@ -92,7 +95,7 @@ const util = {
},

gclientSync: (options = {}) => {
runGClient(['sync', '--force', '--nohooks', '--with_branch_heads'], options)
runGClient(['sync', '--force', '--nohooks', '--with_branch_heads', '--with_tags'], options)
},

gclientRunhooks: (options = {}) => {
Expand Down
1 change: 1 addition & 0 deletions scripts/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ program
.version(process.env.npm_package_version)
.option('--gclient_file <file>', 'gclient config file location')
.option('--gclient_verbose', 'verbose output for gclient')
.option('--gclient_cachedir <directory>', 'cache directory of git mirrors for gclient')
.option('--run_hooks', 'run gclient hooks')
.option('--run_sync', 'run gclient sync')
.option('--submodule_sync', 'run submodule sync')
Expand Down

0 comments on commit 437d50e

Please sign in to comment.