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
dd97133d
Unverified
Commit
dd97133d
authored
Mar 09, 2022
by
Jenn Magder
Committed by
GitHub
Mar 09, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove tool crash git.io link shortener (#99574)
parent
c8538873
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
4 additions
and
97 deletions
+4
-97
context_runner.dart
packages/flutter_tools/lib/src/context_runner.dart
+0
-1
crash_reporting.dart
...ages/flutter_tools/lib/src/reporting/crash_reporting.dart
+1
-5
github_template.dart
...ages/flutter_tools/lib/src/reporting/github_template.dart
+2
-32
crash_reporting_test.dart
...lutter_tools/test/general.shard/crash_reporting_test.dart
+0
-2
github_template_test.dart
...lutter_tools/test/general.shard/github_template_test.dart
+1
-37
fake_http_client.dart
packages/flutter_tools/test/src/fake_http_client.dart
+0
-20
No files found.
packages/flutter_tools/lib/src/context_runner.dart
View file @
dd97133d
...
...
@@ -181,7 +181,6 @@ Future<T> runInContext<T>(
fileSystem:
globals
.
fs
,
logger:
globals
.
logger
,
flutterProjectFactory:
globals
.
projectFactory
,
client:
globals
.
httpClientFactory
?.
call
()
??
HttpClient
(),
),
DevFSConfig:
()
=>
DevFSConfig
(),
DeviceManager:
()
=>
FlutterDeviceManager
(
...
...
packages/flutter_tools/lib/src/reporting/crash_reporting.dart
View file @
dd97133d
...
...
@@ -59,16 +59,13 @@ class CrashReporter {
required
FileSystem
fileSystem
,
required
Logger
logger
,
required
FlutterProjectFactory
flutterProjectFactory
,
required
HttpClient
client
,
})
:
_fileSystem
=
fileSystem
,
_logger
=
logger
,
_flutterProjectFactory
=
flutterProjectFactory
,
_client
=
client
;
_flutterProjectFactory
=
flutterProjectFactory
;
final
FileSystem
_fileSystem
;
final
Logger
_logger
;
final
FlutterProjectFactory
_flutterProjectFactory
;
final
HttpClient
_client
;
/// Prints instructions for filing a bug about the crash.
Future
<
void
>
informUser
(
CrashDetails
details
,
File
crashFile
)
async
{
...
...
@@ -86,7 +83,6 @@ class CrashReporter {
fileSystem:
_fileSystem
,
logger:
_logger
,
flutterProjectFactory:
_flutterProjectFactory
,
client:
_client
,
);
final
String
gitHubTemplateURL
=
await
gitHubTemplateCreator
.
toolCrashIssueTemplateGitHubURL
(
...
...
packages/flutter_tools/lib/src/reporting/github_template.dart
View file @
dd97133d
...
...
@@ -25,16 +25,13 @@ class GitHubTemplateCreator {
required
FileSystem
fileSystem
,
required
Logger
logger
,
required
FlutterProjectFactory
flutterProjectFactory
,
required
HttpClient
client
,
})
:
_fileSystem
=
fileSystem
,
_logger
=
logger
,
_flutterProjectFactory
=
flutterProjectFactory
,
_client
=
client
;
_flutterProjectFactory
=
flutterProjectFactory
;
final
FileSystem
_fileSystem
;
final
Logger
_logger
;
final
FlutterProjectFactory
_flutterProjectFactory
;
final
HttpClient
_client
;
static
String
toolCrashSimilarIssuesURL
(
String
errorString
)
{
return
'https://github.com/flutter/flutter/issues?q=is%3Aissue+
${Uri.encodeQueryComponent(errorString)}
'
;
...
...
@@ -110,13 +107,11 @@ $doctorText
${_projectMetadataInformation()}
'''
;
final
String
fullURL
=
'https://github.com/flutter/flutter/issues'
return
'https://github.com/flutter/flutter/issues'
'/new'
// We split this here to appease our lint that looks for bad "new bug" links.
'?title=
${Uri.encodeQueryComponent(title)}
'
'&body=
${Uri.encodeQueryComponent(body)}
'
'&labels=
${Uri.encodeQueryComponent('tool,severe: crash')}
'
;
return
_shortURL
(
fullURL
);
}
/// Provide information about the Flutter project in the working directory, if present.
...
...
@@ -169,29 +164,4 @@ ${_projectMetadataInformation()}
return
exception
.
toString
();
}
}
/// Shorten GitHub URL with git.io API.
///
/// See https://github.blog/2011-11-10-git-io-github-url-shortener.
Future
<
String
>
_shortURL
(
String
fullURL
)
async
{
String
?
url
;
try
{
_logger
.
printTrace
(
'Attempting git.io shortener:
$fullURL
'
);
final
List
<
int
>
bodyBytes
=
utf8
.
encode
(
'url=
${Uri.encodeQueryComponent(fullURL)}
'
);
final
HttpClientRequest
request
=
await
_client
.
postUrl
(
Uri
.
parse
(
'https://git.io'
));
request
.
headers
.
set
(
HttpHeaders
.
contentLengthHeader
,
bodyBytes
.
length
.
toString
());
request
.
add
(
bodyBytes
);
final
HttpClientResponse
response
=
await
request
.
close
();
if
(
response
.
statusCode
==
201
)
{
url
=
response
.
headers
[
HttpHeaders
.
locationHeader
]?.
first
;
}
else
{
_logger
.
printTrace
(
'Failed to shorten GitHub template URL. Server responded with HTTP status code
${response.statusCode}
'
);
}
}
on
Exception
catch
(
sendError
)
{
_logger
.
printTrace
(
'Failed to shorten GitHub template URL:
$sendError
'
);
}
return
url
??
fullURL
;
}
}
packages/flutter_tools/test/general.shard/crash_reporting_test.dart
View file @
dd97133d
...
...
@@ -19,7 +19,6 @@ import 'package:http/testing.dart';
import
'package:test/fake.dart'
;
import
'../src/common.dart'
;
import
'../src/fake_http_client.dart'
;
import
'../src/fake_process_manager.dart'
;
void
main
(
)
{
...
...
@@ -83,7 +82,6 @@ void main() {
fileSystem:
fs
,
logger:
logger
,
flutterProjectFactory:
FlutterProjectFactory
(
fileSystem:
fs
,
logger:
logger
),
client:
FakeHttpClient
.
any
(),
);
final
File
file
=
fs
.
file
(
'flutter_00.log'
);
...
...
packages/flutter_tools/test/general.shard/github_template_test.dart
View file @
dd97133d
...
...
@@ -14,9 +14,6 @@ import 'package:flutter_tools/src/reporting/github_template.dart';
import
'../src/common.dart'
;
import
'../src/context.dart'
;
import
'../src/fake_http_client.dart'
;
const
String
_kShortURL
=
'https://www.example.com/short'
;
void
main
(
)
{
BufferLogger
logger
;
...
...
@@ -157,41 +154,10 @@ void main() {
error
=
ArgumentError
(
'argument error message'
);
});
testUsingContext
(
'shortened'
,
()
async
{
final
GitHubTemplateCreator
creator
=
GitHubTemplateCreator
(
fileSystem:
fs
,
logger:
logger
,
client:
FakeHttpClient
.
list
(<
FakeRequest
>[
FakeRequest
(
Uri
.
parse
(
'https://git.io'
),
method:
HttpMethod
.
post
,
response:
const
FakeResponse
(
statusCode:
201
,
headers:
<
String
,
List
<
String
>>{
HttpHeaders
.
locationHeader
:
<
String
>[
_kShortURL
],
}
))
]),
flutterProjectFactory:
FlutterProjectFactory
(
fileSystem:
fs
,
logger:
logger
,
),
);
expect
(
await
creator
.
toolCrashIssueTemplateGitHubURL
(
command
,
error
,
stackTrace
,
doctorText
),
_kShortURL
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
.
test
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
testUsingContext
(
'with network failure'
,
()
async
{
testUsingContext
(
'shows GitHub issue URL'
,
()
async
{
final
GitHubTemplateCreator
creator
=
GitHubTemplateCreator
(
fileSystem:
fs
,
logger:
logger
,
client:
FakeHttpClient
.
list
(<
FakeRequest
>[
FakeRequest
(
Uri
.
parse
(
'https://git.io'
),
method:
HttpMethod
.
post
,
response:
const
FakeResponse
(
statusCode:
500
,
))
]),
flutterProjectFactory:
FlutterProjectFactory
(
fileSystem:
fs
,
logger:
logger
,
...
...
@@ -207,7 +173,6 @@ void main() {
'eport%0A%60%60%60%0A%0A%23%23+Flutter+Application+Metadata%0ANo+pubspec+in+working+d'
'irectory.%0A&labels=tool%2Csevere%3A+crash'
);
expect
(
logger
.
traceText
,
contains
(
'Failed to shorten GitHub template URL'
));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
.
test
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
...
...
@@ -217,7 +182,6 @@ void main() {
final
GitHubTemplateCreator
creator
=
GitHubTemplateCreator
(
fileSystem:
fs
,
logger:
logger
,
client:
FakeHttpClient
.
any
(),
flutterProjectFactory:
FlutterProjectFactory
(
fileSystem:
fs
,
logger:
logger
,
...
...
packages/flutter_tools/test/src/fake_http_client.dart
View file @
dd97133d
...
...
@@ -56,26 +56,6 @@ String _toMethodString(HttpMethod method) {
}
}
/// Override the creation of all [HttpClient] objects with a zone injection.
///
/// This should only be used when the http client cannot be set directly, such as
/// when testing `package:http` code.
Future
<
void
>
overrideHttpClients
(
Future
<
void
>
Function
()
callback
,
FakeHttpClient
httpClient
)
async
{
final
HttpOverrides
overrides
=
_FakeHttpClientOverrides
(
httpClient
);
await
HttpOverrides
.
runWithHttpOverrides
(
callback
,
overrides
);
}
class
_FakeHttpClientOverrides
extends
HttpOverrides
{
_FakeHttpClientOverrides
(
this
.
httpClient
);
final
FakeHttpClient
httpClient
;
@override
HttpClient
createHttpClient
(
SecurityContext
?
context
)
{
return
httpClient
;
}
}
/// Create a fake request that configures the [FakeHttpClient] to respond
/// with the provided [response].
///
...
...
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