Unverified Commit 9118d3d7 authored by Janice Collins's avatar Janice Collins Committed by GitHub

Add branch to footer information in flutter docs (#20711)

parent 1993a673
......@@ -193,22 +193,31 @@ ArgParser _createArgsParser() {
return parser;
}
final RegExp gitBranchRegexp = new RegExp(r'^## (.*)');
void createFooter(String footerPath) {
const int kGitRevisionLength = 10;
final ProcessResult gitResult = Process.runSync('git', <String>['rev-parse', 'HEAD']);
ProcessResult gitResult = Process.runSync('git', <String>['rev-parse', 'HEAD']);
if (gitResult.exitCode != 0)
throw 'git exit with non-zero exit code: ${gitResult.exitCode}';
throw 'git rev-parse exit with non-zero exit code: ${gitResult.exitCode}';
String gitRevision = gitResult.stdout.trim();
gitResult = Process.runSync('git', <String>['status', '-b', '--porcelain']);
if (gitResult.exitCode != 0)
throw 'git status exit with non-zero exit code: ${gitResult.exitCode}';
final Match gitBranchMatch = gitBranchRegexp.firstMatch(
gitResult.stdout.trim().split('\n').first);
final String gitBranchOut = gitBranchMatch == null ? '' : '• </span class="no-break">${gitBranchMatch.group(1)}</span>';
gitRevision = gitRevision.length > kGitRevisionLength ? gitRevision.substring(0, kGitRevisionLength) : gitRevision;
final String timestamp = new DateFormat('yyyy-MM-dd HH:mm').format(new DateTime.now());
new File(footerPath).writeAsStringSync(
'• </span class="no-break">$timestamp<span> '
'• </span class="no-break">$gitRevision</span>'
);
new File(footerPath).writeAsStringSync(<String>[
'• </span class="no-break">$timestamp<span>',
'• </span class="no-break">$gitRevision</span>',
gitBranchOut].join(' '));
}
void sanityCheckDocs() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment