-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(aft): Remove libgit2dart dependency (#3562)
* refactor(aft): Remove `libgit2dart` dependency * chore(repo): Remove `libgit2dart` submodule * ci: Remove `libgit2dart` patches * chore(repo): Remove `libgit2` references from READMEs
- Loading branch information
Showing
23 changed files
with
178 additions
and
200 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
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
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
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
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
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
Submodule libgit2dart
deleted from
34d492
This file was deleted.
Oops, something went wrong.
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
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
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,65 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import 'dart:convert'; | ||
|
||
import 'package:git/git.dart'; | ||
|
||
extension GitHelpers on GitDir { | ||
/// Returns the [CommitRef] for the current `HEAD`. | ||
Future<CommitRef> get head => commitRef('HEAD'); | ||
|
||
/// Returns the [CommitRef] for the given [commit]. | ||
Future<CommitRef> commitRef(String commit) async { | ||
if (_sha1Regex.hasMatch(commit)) { | ||
return ( | ||
commit, | ||
await commitFromRevision(commit), | ||
); | ||
} | ||
return ( | ||
revParse(commit), | ||
commitFromRevision(commit), | ||
).wait; | ||
} | ||
|
||
/// Runs a `git diff` between [baseTree] and [headTree] and returns the list | ||
/// of filepaths changed between the two commits. | ||
Future<List<String>> diffTrees(String baseTree, String headTree) async { | ||
final diff = await runCommand( | ||
['diff', '--raw', '$baseTree..$headTree'], | ||
); | ||
final diffs = LineSplitter.split(diff.stdout as String); | ||
final changedPaths = <String>[]; | ||
for (final diff in diffs) { | ||
// Example line: | ||
// :100644 100644 475c1a84d 3738675a1 M packages/aws_sdk/smoke_test/test/build_verify_test.dart | ||
changedPaths.add(diff.split(_whitespace).last); | ||
} | ||
return changedPaths; | ||
} | ||
|
||
/// Runs `git rev-parse` with the provided [input]. | ||
Future<String> revParse(String input) async { | ||
final revParse = await runCommand(['rev-parse', input]); | ||
return (revParse.stdout as String).trim(); | ||
} | ||
|
||
/// Lists all commits, in reverse chronological order, between [baseCommit] | ||
/// and [headCommit]. | ||
Stream<CommitRef> revList(String baseCommit, String headCommit) async* { | ||
final revList = await runCommand( | ||
['rev-list', '$baseCommit..$headCommit'], | ||
); | ||
final commits = LineSplitter.split((revList.stdout as String).trim()); | ||
for (final oid in commits) { | ||
yield await commitRef(oid); | ||
} | ||
} | ||
|
||
static final _sha1Regex = RegExp(r'[a-f0-9]{40}'); | ||
static final _whitespace = RegExp(r'\s+'); | ||
} | ||
|
||
/// A [Commit] and its associated SHA. | ||
typedef CommitRef = (String oid, Commit commit); |
Oops, something went wrong.