-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
737a4a9
commit 85f9d63
Showing
3 changed files
with
54 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div style="padding-left: 2em; padding-bottom: 1em"> | ||
No changed dependencies | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,29 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:changelog_bubbler/src/change_type.dart'; | ||
import 'package:changelog_bubbler/src/dependency_type.dart'; | ||
import 'package:changelog_bubbler/src/package_wrapper.dart'; | ||
import 'package:path/path.dart' as p; | ||
|
||
class DependencyPair { | ||
final PackageWrapper? previous; | ||
final PackageWrapper? current; | ||
// TODO add CHANGETYPE here | ||
// eg added/removed/updated | ||
|
||
DependencyPair({ | ||
this.previous, | ||
this.current, | ||
}); | ||
|
||
String? get trimmedUrl => previous?.trimmedUrl ?? current?.trimmedUrl; | ||
DependencyType get dependencyType => | ||
(previous?.dependencyType ?? current?.dependencyType)!; | ||
|
||
String getChangelogDiff() { | ||
final previousChangelog = File(p.join(previous?.repoPath, changelogName)); | ||
final currentChangelog = File(p.join(currentPath, changelogName)); | ||
}) : assert(previous != null || current != null, | ||
'Either previous or current must not be null'); | ||
|
||
if (!previousChangelog.existsSync() || !currentChangelog.existsSync()) { | ||
return '$changelogName not found'; | ||
ChangeType get changeType { | ||
if (previous == null) { | ||
return ChangeType.added; | ||
} | ||
final previousString = previousChangelog.readAsStringSync(); | ||
final currentString = currentChangelog.readAsStringSync(); | ||
final diff = currentString.replaceFirst(previousString, ''); | ||
if (diff.isEmpty) { | ||
return '$changelogName did not contain changes'; | ||
if (current == null) { | ||
return ChangeType.removed; | ||
} | ||
|
||
return diff; | ||
return ChangeType.updated; | ||
} | ||
|
||
String get name => (previous?.name ?? current?.name)!; | ||
String? get trimmedUrl => previous?.trimmedUrl ?? current?.trimmedUrl; | ||
DependencyType get dependencyType => | ||
(previous?.dependencyType ?? current?.dependencyType)!; | ||
} |