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
ab9df836
Unverified
Commit
ab9df836
authored
Jun 16, 2021
by
Hans Muller
Committed by
GitHub
Jun 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Retry dev/snippets git status, deflake snippets generator (#84728)
parent
8d506c77
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
9 deletions
+36
-9
main.dart
dev/snippets/lib/main.dart
+36
-9
No files found.
dev/snippets/lib/main.dart
View file @
ab9df836
...
...
@@ -21,19 +21,46 @@ const String _kTemplateOption = 'template';
const
String
_kTypeOption
=
'type'
;
const
String
_kShowDartPad
=
'dartpad'
;
class
GitStatusFailed
implements
Exception
{
GitStatusFailed
(
this
.
gitResult
);
final
ProcessResult
gitResult
;
@override
String
toString
()
=>
'git status exited with a non-zero exit code:
${gitResult.exitCode}
:
\n
${gitResult.stderr}
\n
${gitResult.stdout}
'
;
}
String
getChannelName
(
)
{
final
RegExp
gitBranchRegexp
=
RegExp
(
r'^## (?<branch>.*)'
);
final
ProcessResult
gitResult
=
Process
.
runSync
(
'git'
,
<
String
>[
'status'
,
'-b'
,
'--porcelain'
],
environment:
<
String
,
String
>{
'GIT_TRACE'
:
'2'
,
'GIT_TRACE_SETUP'
:
'2'
,
},
includeParentEnvironment:
true
);
if
(
gitResult
.
exitCode
!=
0
)
throw
'git status exit with non-zero exit code:
${gitResult.exitCode}
:
${gitResult.stderr}
'
;
final
RegExpMatch
?
gitBranchMatch
=
gitBranchRegexp
.
firstMatch
(
(
gitResult
.
stdout
as
String
).
trim
().
split
(
'
\n
'
).
first
);
final
ProcessResult
gitResult
=
Process
.
runSync
(
'git'
,
<
String
>[
'status'
,
'-b'
,
'--porcelain'
],
environment:
<
String
,
String
>{
'GIT_TRACE'
:
'2'
,
'GIT_TRACE_SETUP'
:
'2'
},
includeParentEnvironment:
true
);
if
(
gitResult
.
exitCode
!=
0
)
{
throw
GitStatusFailed
(
gitResult
);
}
final
RegExpMatch
?
gitBranchMatch
=
gitBranchRegexp
.
firstMatch
((
gitResult
.
stdout
as
String
).
trim
().
split
(
'
\n
'
).
first
);
return
gitBranchMatch
==
null
?
'<unknown>'
:
gitBranchMatch
.
namedGroup
(
'branch'
)!.
split
(
'...'
).
first
;
}
// This is a hack to workaround the fact that git status inexplicably fails
// (random non-zero error code) about 2% of the time.
String
getChannelNameWithRetries
(
)
{
int
retryCount
=
0
;
while
(
retryCount
<
2
)
{
try
{
return
getChannelName
();
}
on
GitStatusFailed
catch
(
e
)
{
retryCount
+=
1
;
stderr
.
write
(
'git status failed, retrying (
$retryCount
)
\n
Error report:
\n
$e
'
);
}
}
return
getChannelName
();
}
/// Generates snippet dartdoc output for a given input, and creates any sample
/// applications needed by the snippet.
void
main
(
List
<
String
>
argList
)
{
...
...
@@ -185,7 +212,7 @@ void main(List<String> argList) {
?
int
.
tryParse
(
environment
[
'SOURCE_LINE'
]!)
:
null
,
'id'
:
id
.
join
(
'.'
),
'channel'
:
getChannelName
(),
'channel'
:
getChannelName
WithRetries
(),
'serial'
:
serial
,
'package'
:
packageName
,
'library'
:
libraryName
,
...
...
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