Add branch to footer information in flutter docs (#20711)
This commit is contained in:
parent
1993a67381
commit
9118d3d715
@ -193,22 +193,31 @@ ArgParser _createArgsParser() {
|
|||||||
return parser;
|
return parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final RegExp gitBranchRegexp = new RegExp(r'^## (.*)');
|
||||||
|
|
||||||
void createFooter(String footerPath) {
|
void createFooter(String footerPath) {
|
||||||
const int kGitRevisionLength = 10;
|
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)
|
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();
|
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;
|
gitRevision = gitRevision.length > kGitRevisionLength ? gitRevision.substring(0, kGitRevisionLength) : gitRevision;
|
||||||
|
|
||||||
final String timestamp = new DateFormat('yyyy-MM-dd HH:mm').format(new DateTime.now());
|
final String timestamp = new DateFormat('yyyy-MM-dd HH:mm').format(new DateTime.now());
|
||||||
|
|
||||||
new File(footerPath).writeAsStringSync(
|
new File(footerPath).writeAsStringSync(<String>[
|
||||||
'• </span class="no-break">$timestamp<span> '
|
'• </span class="no-break">$timestamp<span>',
|
||||||
'• </span class="no-break">$gitRevision</span>'
|
'• </span class="no-break">$gitRevision</span>',
|
||||||
);
|
gitBranchOut].join(' '));
|
||||||
}
|
}
|
||||||
|
|
||||||
void sanityCheckDocs() {
|
void sanityCheckDocs() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user