Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolved warnings #328

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions example/release_notes.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import 'dart:html';

import 'common.dart';
import 'package:pub_semver/pub_semver.dart';

import 'common.dart';

late DivElement releasesDiv;

Future<void> main() async {
Expand All @@ -28,12 +29,12 @@ Future<String> loadReleaseNotes() async {
print('No unreleased PRs');
return '';
}
var semvers = Set<String>();
for (var pr in unreleasedPRs) {
var semvers = <String>{};
for (final pr in unreleasedPRs) {
var prlabels = pr.labels
.where((element) => element.name.startsWith('semver:'))
.toList();
for (var l in prlabels) {
for (final l in prlabels) {
semvers.add(l.name);
}
}
Expand All @@ -50,7 +51,9 @@ Future<String> loadReleaseNotes() async {
newVersion = latestVersion.nextPatch.toString();
}
print(newVersion);
if (newVersion.isEmpty) return '';
if (newVersion.isEmpty) {
return '';
}

var notes = await github.repositories.generateReleaseNotes(CreateReleaseNotes(
slug.owner, slug.name, newVersion,
Expand Down
1 change: 0 additions & 1 deletion test/src/mocks.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import 'package:mockito/mockito.dart' as _i1;
// ignore_for_file: prefer_const_constructors
// ignore_for_file: unnecessary_overrides
// ignore_for_file: unnecessary_parenthesis
// ignore_for_file: camel_case_types

class _FakeClient_0 extends _i1.Fake implements _i2.Client {}

Expand Down
36 changes: 22 additions & 14 deletions tool/release_unreleased_prs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ Future<void> main(List<String> args) async {
for (final i in unreleased) {
await _gh.issues.removeLabelForIssue(_slug, i.number, 'unreleased');
await _gh.issues.addLabelsToIssue(_slug, i.number, ['released']);
await _gh.issues.createComment(_slug, i.number, 'Released in version $nextVersion https://github.com/$fullrepo/releases/tag/$nextVersion');
await _gh.issues.createComment(_slug, i.number,
'Released in version $nextVersion https://github.com/$fullrepo/releases/tag/$nextVersion');
}

exit(0);
Expand Down Expand Up @@ -92,15 +93,21 @@ Future<Version> getLatestVersion(RepositorySlug slug) async {

Future<List<Issue>> getUnreleasedPRs() async {
print('Loading unreleased PRs...');
var prs = await _gh.search.issues('repo:${_slug.fullName} is:pull-request label:unreleased -label:no_release_on_merge state:closed', sort: 'desc').toList();
var prs = await _gh.search
.issues(
'repo:${_slug.fullName} is:pull-request label:unreleased -label:no_release_on_merge state:closed',
sort: 'desc')
.toList();
print('${prs.length} loaded');
return prs;
}

String getNextVersion(Version currentVersion, List<Issue> unreleased) {
var semvers = Set<String>();
for (final pr in unreleased){
var prlabels = pr.labels.where((element) => element.name.startsWith('semver:')).toList();
var semvers = <String>{};
for (final pr in unreleased) {
var prlabels = pr.labels
.where((element) => element.name.startsWith('semver:'))
.toList();
for (final l in prlabels) {
semvers.add(l.name);
}
Expand All @@ -118,13 +125,14 @@ String getNextVersion(Version currentVersion, List<Issue> unreleased) {
return newVersion;
}

Future<String> generateReleaseNotes(String fromVersion, String newVersion) async {
Future<String> generateReleaseNotes(
String fromVersion, String newVersion) async {
var notes = await _gh.repositories.generateReleaseNotes(CreateReleaseNotes(
_slug.owner, _slug.name, newVersion,
previousTagName: fromVersion));

var releaseNotes = notes.body.replaceFirst('## What\'s Changed', '');

var r = '## $newVersion\n$releaseNotes';
print(r);
return r;
Expand All @@ -147,8 +155,8 @@ void updatePubspec(String newVersion) {
}

Future<Release> createRelease(String version, String target) async {
print('Creating release ...');
var release = await _gh.repositories.createRelease(
print('Creating release ...');
var release = await _gh.repositories.createRelease(
_slug,
CreateRelease.from(
tagName: version,
Expand All @@ -158,13 +166,13 @@ Future<Release> createRelease(String version, String target) async {
isDraft: false,
isPrerelease: false));

print('Release ${release.name} created ${release.createdAt}');
print(release.body);
return release;
print('Release ${release.name} created ${release.createdAt}');
print(release.body);
return release;
}

void commitUpdates(String version) {
run('git add pubspec.yaml CHANGELOG.md');
run('git', rest: ['commit', '-m', 'prep $version']);
run('git push');
}
}