forked from libgit2/php-git
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path002-07-commit_create.phpt
More file actions
50 lines (45 loc) · 1.34 KB
/
002-07-commit_create.phpt
File metadata and controls
50 lines (45 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
--TEST--
Check for Git2\Commit::getCommitter
--SKIPIF--
<?php if (!extension_loaded("git2")) print "skip"; ?>
--FILE--
<?php
date_default_timezone_set('Asia/Tokyo');
$path = __DIR__ . '/mock/002-07';
if (file_exists($path)) {
`rm -rf {$path}`;
}
$repo = Git2\Repository::init($path, true);
$oid = $repo->write("Hello World", 3);
$committer = new Git2\Signature("Shuhei Tanuma San","[email protected]",new DateTime("@1327164747"));
$bld = new Git2\TreeBuilder();
$bld->insert(new Git2\TreeEntry(array(
"name" => "README.txt",
"oid" => $oid,
"attributes" => octdec('100644'),
)));
$tree = $bld->write($repo);
$parent = "";
$parents = array();
$parent = Git2\Commit::create($repo, array(
"author" => $author,
"committer" => $committer,
"message" => "Hello World",
"tree" => $tree,
"parents" => $parents,
));
$commit = $repo->lookup($parent);
printf("commit_id: %s\n",$parent);
printf("author: %s\n", $commit->getAuthor()->name);
printf("email: %s\n", $commit->getAuthor()->email);
printf("time: %s\n", $commit->getAuthor()->time->getTimestamp());
echo PHP_EOL;
printf("%s\n", $commit->getMessage());
`rm -rf {$path}`;
--EXPECT--
commit_id: 239442d8e6cdbd904e150e25778cc45024b60d51
author: Shuhei Tanuma
email: [email protected]
time: 1327164747
Hello World