Created
February 7, 2013 16:02
-
-
Save aaronj1335/4731913 to your computer and use it in GitHub Desktop.
hoping to make this a bit more understandable...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commands = | |
stage: (config)-> | |
if config.clobber and exists config.stagingdir | |
rm "-rf", config.stagingdir | |
mkdir "-p", config.stagingdir unless exists config.stagingdir | |
cloneAll(config) | |
report: (config)-> | |
# first check if we need to clone the repos | |
preRequisites = if config.stagetoo then [commands.stage(config)] else [] | |
Q.all(preRequisites).then(()-> | |
Q.all [readManifest(config), readJsons(config)] | |
).then(([[manifest, excludes], jsons])-> | |
# add the info we read from: | |
# (a) "manifest" - the last build's manifest | |
# (b) "excludes" the list of repos that lattice handles, and | |
# (c) "jsons" # - the package.json files for all the repos | |
# to the 'config' for tracking | |
config.repos.forEach (repo, i)-> | |
repo.json = jsons[i] | |
repo.manifest = manifest.filter((m)-> m.repo == repo.name)[0] | |
config.excludes = excludes | |
# get the git log for all the repos | |
Q.all config.repos.map((repo)-> | |
gitLog repo | |
) | |
).then((logs)-> | |
# add the logs to the 'config' object for tracking | |
logs.forEach (log, i)-> | |
config.repos[i].log = log | |
config.repos[i].newCommits = !!log.length | |
# get the current commit hash (git rev-parse) for each repo | |
Q.all config.repos.map((repo)-> | |
gitRevParse repo | |
) | |
).then((revs)-> | |
# add the commit hashes to the 'config' object for tracking | |
revs.forEach (rev, i)-> config.repos[i].sha = rev | |
# get the list of repos we actually need to make reports on | |
reportable = config.repos.filter (repo)-> | |
config.excludes.indexOf(repo.url) < 0 | |
# create the new manifest file | |
manifest = reportable | |
.map((repo)-> "#{repo.name}:#{repo.json.version}:#{repo.sha}") | |
.join("\n") | |
# create the new changelog | |
changelog = reportable | |
.filter((repo)-> repo.newCommits | |
.map((repo)-> repo.log) | |
.join("\n") | |
# write the files out to disk | |
Q.all [ | |
writeFile(config.manifestout, manifest), | |
writeFile(config.changelogout, changelog) | |
] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment