Skip to content

Commit

Permalink
checkout: Set the file mode
Browse files Browse the repository at this point in the history
Dart unfortunately doesn't provide a way, however this convenient
package 'os' allows us to change it via FFI.

Related to dart-lang/sdk#15078
  • Loading branch information
vHanda committed Jun 29, 2021
1 parent 267eafb commit dc02a2a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/checkout.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import 'dart:io';

import 'package:path/path.dart' as p;
import 'package:os/file_system.dart' as os_fs;

import 'package:dart_git/dart_git.dart';
import 'package:dart_git/diff_commit.dart';
Expand Down Expand Up @@ -128,7 +131,10 @@ extension Checkout on GitRepository {
await fs
.directory(p.join(workTree, p.dirname(to.path)))
.create(recursive: true);
await fs.file(p.join(workTree, to.path)).writeAsBytes(blobObj.blobData);

var filePath = p.join(workTree, to.path);
await fs.file(filePath).writeAsBytes(blobObj.blobData);
os_fs.chmodSync(File(filePath), change.to!.mode.val);

await index.updatePath(to.path, to.hash);
} else if (change.deleted) {
Expand Down
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ dependencies:
file: ^6.1.0
freezed_annotation: ^0.14.1
meta: ^1.3.0
os:
git: https://github.com/GitJournal/os.git
path: ^1.8.0
quiver: ^3.0.0
tuple: ^2.0.0
Expand Down

0 comments on commit dc02a2a

Please sign in to comment.