mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
feat(checkout): add ability to dry run checkout
This commit is contained in:
parent
75b9ed6b57
commit
101cf90875
2 changed files with 21 additions and 0 deletions
|
@ -550,6 +550,10 @@ class GitCheckout {
|
||||||
/// Normally checkout writes the index upon completion; this prevents that.
|
/// Normally checkout writes the index upon completion; this prevents that.
|
||||||
static const dontWriteIndex = GitCheckout._(8388608, 'dontWriteIndex');
|
static const dontWriteIndex = GitCheckout._(8388608, 'dontWriteIndex');
|
||||||
|
|
||||||
|
/// Show what would be done by a checkout. Stop after sending
|
||||||
|
/// notifications; don't update the working directory or index.
|
||||||
|
static const dryRun = GitCheckout._(16777216, 'dryRun');
|
||||||
|
|
||||||
static const List<GitCheckout> values = [
|
static const List<GitCheckout> values = [
|
||||||
none,
|
none,
|
||||||
safe,
|
safe,
|
||||||
|
@ -571,6 +575,7 @@ class GitCheckout {
|
||||||
conflictStyleDiff3,
|
conflictStyleDiff3,
|
||||||
dontRemoveExisting,
|
dontRemoveExisting,
|
||||||
dontWriteIndex,
|
dontWriteIndex,
|
||||||
|
dryRun
|
||||||
];
|
];
|
||||||
|
|
||||||
int get value => _value;
|
int get value => _value;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'package:libgit2dart/src/git_types.dart';
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -93,5 +94,20 @@ void main() {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('successfully performs dry run checkout', () {
|
||||||
|
final index = repo.index;
|
||||||
|
expect(index.length, 4);
|
||||||
|
expect(File('${repo.workdir}/another_feature_file').existsSync(), false);
|
||||||
|
|
||||||
|
repo.checkout(
|
||||||
|
refName: 'refs/heads/feature',
|
||||||
|
strategy: {GitCheckout.dryRun},
|
||||||
|
);
|
||||||
|
expect(index.length, 4);
|
||||||
|
expect(File('${repo.workdir}/another_feature_file').existsSync(), false);
|
||||||
|
|
||||||
|
index.free();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue