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

Side by Side Diff: sdk/lib/_internal/pub/test/descriptor/git.dart

Issue 1165473002: Start pulling pub from its own repo. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Code review changes Created 5 years, 6 months 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library descriptor.git;
6
7 import 'dart:async';
8
9 import 'package:path/path.dart' as path;
10 import 'package:scheduled_test/scheduled_test.dart';
11 import 'package:scheduled_test/descriptor.dart';
12
13 import '../../lib/src/git.dart' as git;
14
15 /// Describes a Git repository and its contents.
16 class GitRepoDescriptor extends DirectoryDescriptor {
17 GitRepoDescriptor(String name, List<Descriptor> contents)
18 : super(name, contents);
19
20 /// Creates the Git repository and commits the contents.
21 Future create([String parent]) => schedule(() {
22 return super.create(parent).then((_) {
23 return _runGitCommands(parent, [
24 ['init'],
25 ['add', '.'],
26 ['commit', '-m', 'initial commit']
27 ]);
28 });
29 }, 'creating Git repo:\n${describe()}');
30
31 /// Writes this descriptor to the filesystem, than commits any changes from
32 /// the previous structure to the Git repo.
33 ///
34 /// [parent] defaults to [defaultRoot].
35 Future commit([String parent]) => schedule(() {
36 return super.create(parent).then((_) {
37 return _runGitCommands(parent, [
38 ['add', '.'],
39 ['commit', '-m', 'update']
40 ]);
41 });
42 }, 'committing Git repo:\n${describe()}');
43
44 /// Return a Future that completes to the commit in the git repository
45 /// referred to by [ref] at the current point in the scheduled test run.
46 ///
47 /// [parent] defaults to [defaultRoot].
48 Future<String> revParse(String ref, [String parent]) => schedule(() {
49 return _runGit(['rev-parse', ref], parent).then((output) => output[0]);
50 }, 'parsing revision $ref for Git repo:\n${describe()}');
51
52 /// Schedule a Git command to run in this repository.
53 ///
54 /// [parent] defaults to [defaultRoot].
55 Future runGit(List<String> args, [String parent]) => schedule(() {
56 return _runGit(args, parent);
57 }, "running 'git ${args.join(' ')}' in Git repo:\n${describe()}");
58
59 Future _runGitCommands(String parent, List<List<String>> commands) =>
60 Future.forEach(commands, (command) => _runGit(command, parent));
61
62 Future<List<String>> _runGit(List<String> args, String parent) {
63 // Explicitly specify the committer information. Git needs this to commit
64 // and we don't want to rely on the buildbots having this already set up.
65 var environment = {
66 'GIT_AUTHOR_NAME': 'Pub Test',
67 'GIT_AUTHOR_EMAIL': 'pub@dartlang.org',
68 'GIT_COMMITTER_NAME': 'Pub Test',
69 'GIT_COMMITTER_EMAIL': 'pub@dartlang.org'
70 };
71
72 if (parent == null) parent = defaultRoot;
73 return git.run(args,
74 workingDir: path.join(parent, name),
75 environment: environment);
76 }
77 }
78
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub/test/descriptor.dart ('k') | sdk/lib/_internal/pub/test/descriptor/tar.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698