Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
2ba15a5a
Unverified
Commit
2ba15a5a
authored
Jul 19, 2021
by
Christopher Fujino
Committed by
GitHub
Jul 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
teach dartdoc.dart about LUCI_BRANCH env var (#86592)
parent
eb648523
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
2 deletions
+98
-2
dartdoc.dart
dev/tools/dartdoc.dart
+17
-2
dartdoc_test.dart
dev/tools/test/dartdoc_test.dart
+81
-0
No files found.
dev/tools/dartdoc.dart
View file @
2ba15a5a
...
...
@@ -7,7 +7,9 @@ import 'dart:io';
import
'package:args/args.dart'
;
import
'package:intl/intl.dart'
;
import
'package:meta/meta.dart'
;
import
'package:path/path.dart'
as
path
;
import
'package:platform/platform.dart'
;
import
'package:process/process.dart'
;
import
'dartdoc_checker.dart'
;
...
...
@@ -252,8 +254,21 @@ ArgParser _createArgsParser() {
final
RegExp
gitBranchRegexp
=
RegExp
(
r'^## (.*)'
);
String
getBranchName
(
)
{
final
ProcessResult
gitResult
=
Process
.
runSync
(
'git'
,
<
String
>[
'status'
,
'-b'
,
'--porcelain'
]);
/// Get the name of the release branch.
///
/// On LUCI builds, the git HEAD is detached, so first check for the env
/// variable "LUCI_BRANCH"; if it is not set, fall back to calling git.
String
getBranchName
(
{
@visibleForTesting
Platform
platform
=
const
LocalPlatform
(),
@visibleForTesting
ProcessManager
processManager
=
const
LocalProcessManager
(),
})
{
final
String
?
luciBranch
=
platform
.
environment
[
'LUCI_BRANCH'
];
if
(
luciBranch
!=
null
&&
luciBranch
.
trim
().
isNotEmpty
)
{
return
luciBranch
.
trim
();
}
final
ProcessResult
gitResult
=
processManager
.
runSync
(<
String
>[
'git'
,
'status'
,
'-b'
,
'--porcelain'
]);
if
(
gitResult
.
exitCode
!=
0
)
throw
'git status exit with non-zero exit code:
${gitResult.exitCode}
'
;
final
RegExpMatch
?
gitBranchMatch
=
gitBranchRegexp
.
firstMatch
(
...
...
dev/tools/test/dartdoc_test.dart
0 → 100644
View file @
2ba15a5a
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:platform/platform.dart'
;
import
'package:process/process.dart'
;
import
'package:test/test.dart'
;
import
'../../../packages/flutter_tools/test/src/fake_process_manager.dart'
;
import
'../dartdoc.dart'
show
getBranchName
;
void
main
(
)
{
const
String
branchName
=
'stable'
;
test
(
'getBranchName does not call git if env LUCI_BRANCH provided'
,
()
{
final
Platform
platform
=
FakePlatform
(
environment:
<
String
,
String
>{
'LUCI_BRANCH'
:
branchName
,
},
);
final
ProcessManager
processManager
=
FakeProcessManager
.
empty
();
expect
(
getBranchName
(
platform:
platform
,
processManager:
processManager
,
),
branchName
,
);
});
test
(
'getBranchName calls git if env LUCI_BRANCH not provided'
,
()
{
final
Platform
platform
=
FakePlatform
(
environment:
<
String
,
String
>{},
);
final
ProcessManager
processManager
=
FakeProcessManager
.
list
(
<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'git'
,
'status'
,
'-b'
,
'--porcelain'
],
stdout:
'##
$branchName
'
,
),
],
);
expect
(
getBranchName
(
platform:
platform
,
processManager:
processManager
,
),
branchName
,
);
expect
(
processManager
,
hasNoRemainingExpectations
);
});
test
(
'getBranchName calls git if env LUCI_BRANCH is empty'
,
()
{
final
Platform
platform
=
FakePlatform
(
environment:
<
String
,
String
>{
'LUCI_BRANCH'
:
''
,
},
);
final
ProcessManager
processManager
=
FakeProcessManager
.
list
(
<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'git'
,
'status'
,
'-b'
,
'--porcelain'
],
stdout:
'##
$branchName
'
,
),
],
);
expect
(
getBranchName
(
platform:
platform
,
processManager:
processManager
,
),
branchName
,
);
expect
(
processManager
,
hasNoRemainingExpectations
);
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment