Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Unified Diff: pkg/analysis_server/test/stress/utilities/git.dart

Issue 1461763002: Generalize API, fix bug, sort (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/stress/utilities/git.dart
diff --git a/pkg/analysis_server/test/stress/utilities/git.dart b/pkg/analysis_server/test/stress/utilities/git.dart
index 1f7549d1d79bf237c145544ffca04b6561c8e593..30e45f71585f2ec1bd3123add5f3cd25e9bf6bc2 100644
--- a/pkg/analysis_server/test/stress/utilities/git.dart
+++ b/pkg/analysis_server/test/stress/utilities/git.dart
@@ -10,6 +10,7 @@ library analysis_server.test.stress.utilities.git;
import 'dart:convert';
import 'dart:io';
+import 'package:analyzer/src/util/glob.dart';
import 'package:path/path.dart' as path;
/**
@@ -126,23 +127,18 @@ class CommitDelta {
/**
* Remove any diffs for files that are either (a) outside the given
- * [analysisRoots], or (b) are files that are not being analyzed by the server.
+ * [inclusionPaths], or (b) are files that do not match one of the given
+ * [globPatterns].
*/
- void filterDiffs(List<String> analysisRoots) {
- // TODO(brianwilkerson) Generalize this method by renaming the parameter and
- // passing in the glob patterns. (Or just pass in glob patterns.)
+ void filterDiffs(List<String> inclusionPaths, List<Glob> globPatterns) {
diffRecords.retainWhere((DiffRecord record) {
String filePath = record.srcPath ?? record.dstPath;
- for (String analysisRoot in analysisRoots) {
- if (path.isWithin(analysisRoot, filePath)) {
- // TODO(brianwilkerson) Generalize this by asking the server for the
- // list of glob patterns of files to be analyzed (once there's an API
- // for doing so).
- if (filePath.endsWith('.dart') ||
- filePath.endsWith('.html') ||
- filePath.endsWith('.htm') ||
- filePath.endsWith('.analysisOptions')) {
- return true;
+ for (String inclusionPath in inclusionPaths) {
+ if (path.isWithin(inclusionPath, filePath)) {
+ for (Glob glob in globPatterns) {
+ if (glob.matches(filePath)) {
+ return true;
+ }
}
}
}
@@ -236,88 +232,6 @@ class CommitDelta {
}
/**
- * A representation of the history of a Git repository. This only represents a
- * single linear path in the history graph.
- */
-class LinearCommitHistory {
- /**
- * The repository whose history is being represented.
- */
- final GitRepository repository;
-
- /**
- * The id's (SHA's) of the commits in the repository, with the most recent
- * commit being first and the oldest commit being last.
- */
- final List<String> commitIds;
-
- /**
- * Initialize a commit history for the given [repository] to have the given
- * [commitIds].
- */
- LinearCommitHistory(this.repository, this.commitIds);
-
- /**
- * Return an iterator that can be used to iterate over this commit history.
- */
- LinearCommitHistoryIterator iterator() {
- return new LinearCommitHistoryIterator(this);
- }
-}
-
-/**
- * An iterator over the history of a Git repository.
- */
-class LinearCommitHistoryIterator {
- /**
- * The commit history being iterated over.
- */
- final LinearCommitHistory history;
-
- /**
- * The index of the current commit in the list of [commitIds].
- */
- int currentCommit;
-
- /**
- * Initialize a newly created iterator to iterate over the commits with the
- * given [commitIds];
- */
- LinearCommitHistoryIterator(this.history) {
- currentCommit = history.commitIds.length;
- }
-
- /**
- * Return the SHA1 of the commit after the current commit (the 'dst' of the
- * [next] diff).
- */
- String get dstCommit => history.commitIds[currentCommit - 1];
-
- /**
- * Return the SHA1 of the current commit (the 'src' of the [next] diff).
- */
- String get srcCommit => history.commitIds[currentCommit];
-
- /**
- * Advance to the next commit in the history. Return `true` if it is safe to
- * ask for the [next] diff.
- */
- bool moveNext() {
- if (currentCommit <= 1) {
- return false;
- }
- currentCommit--;
- return true;
- }
-
- /**
- * Return the difference between the current commit and the commit that
- * followed it.
- */
- CommitDelta next() => history.repository.getCommitDiff(srcCommit, dstCommit);
-}
-
-/**
* Representation of a single diff hunk.
*/
class DiffHunk {
@@ -500,7 +414,7 @@ class GitRepository {
* running the command `git diff <blob> <blob>`.
*/
BlobDiff getBlobDiff(String srcBlob, String dstBlob) {
- ProcessResult result = _run(['diff', srcBlob, dstBlob]);
+ ProcessResult result = _run(['diff', '-U0', srcBlob, dstBlob]);
List<String> diffResults = LineSplitter.split(result.stdout).toList();
return new BlobDiff._(diffResults);
}
@@ -513,8 +427,15 @@ class GitRepository {
CommitDelta getCommitDiff(String srcCommit, String dstCommit) {
// Consider --find-renames instead of --no-renames if rename information is
// desired.
- ProcessResult result = _run(['diff', '--raw', '--no-abbrev', '--no-renames',
- '-z', srcCommit, dstCommit]);
+ ProcessResult result = _run([
+ 'diff',
+ '--raw',
+ '--no-abbrev',
+ '--no-renames',
+ '-z',
+ srcCommit,
+ dstCommit
+ ]);
return new CommitDelta._(this, result.stdout);
}
@@ -537,3 +458,85 @@ class GitRepository {
stderrEncoding: UTF8, stdoutEncoding: UTF8, workingDirectory: path);
}
}
+
+/**
+ * A representation of the history of a Git repository. This only represents a
+ * single linear path in the history graph.
+ */
+class LinearCommitHistory {
+ /**
+ * The repository whose history is being represented.
+ */
+ final GitRepository repository;
+
+ /**
+ * The id's (SHA's) of the commits in the repository, with the most recent
+ * commit being first and the oldest commit being last.
+ */
+ final List<String> commitIds;
+
+ /**
+ * Initialize a commit history for the given [repository] to have the given
+ * [commitIds].
+ */
+ LinearCommitHistory(this.repository, this.commitIds);
+
+ /**
+ * Return an iterator that can be used to iterate over this commit history.
+ */
+ LinearCommitHistoryIterator iterator() {
+ return new LinearCommitHistoryIterator(this);
+ }
+}
+
+/**
+ * An iterator over the history of a Git repository.
+ */
+class LinearCommitHistoryIterator {
+ /**
+ * The commit history being iterated over.
+ */
+ final LinearCommitHistory history;
+
+ /**
+ * The index of the current commit in the list of [commitIds].
+ */
+ int currentCommit;
+
+ /**
+ * Initialize a newly created iterator to iterate over the commits with the
+ * given [commitIds];
+ */
+ LinearCommitHistoryIterator(this.history) {
+ currentCommit = history.commitIds.length;
+ }
+
+ /**
+ * Return the SHA1 of the commit after the current commit (the 'dst' of the
+ * [next] diff).
+ */
+ String get dstCommit => history.commitIds[currentCommit - 1];
+
+ /**
+ * Return the SHA1 of the current commit (the 'src' of the [next] diff).
+ */
+ String get srcCommit => history.commitIds[currentCommit];
+
+ /**
+ * Advance to the next commit in the history. Return `true` if it is safe to
+ * ask for the [next] diff.
+ */
+ bool moveNext() {
+ if (currentCommit <= 1) {
+ return false;
+ }
+ currentCommit--;
+ return true;
+ }
+
+ /**
+ * Return the difference between the current commit and the commit that
+ * followed it.
+ */
+ CommitDelta next() => history.repository.getCommitDiff(srcCommit, dstCommit);
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698