summaryrefslogtreecommitdiffstats
path: root/php-gitter-pr47.patch
blob: 007d59810719574ebce1294e2ebf1599b1f6d360 (plain)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
From c02d283c43151120b93e96141df1a8e465b25d8c Mon Sep 17 00:00:00 2001
From: Remi Collet <fedora@famillecollet.com>
Date: Sun, 24 May 2015 08:31:28 +0200
Subject: [PATCH] fix for git 2.4.x

---
 lib/Gitter/Repository.php             | 8 ++++++--
 tests/Gitter/Tests/RepositoryTest.php | 6 +++---
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/lib/Gitter/Repository.php b/lib/Gitter/Repository.php
index 7391125..a40733c 100644
--- a/lib/Gitter/Repository.php
+++ b/lib/Gitter/Repository.php
@@ -244,7 +244,9 @@ public function getBranches()
         // Since we've stripped whitespace, the result "* (detached from "
         // and "* (no branch)" that is displayed in detached HEAD state
         // becomes "(detachedfrom" and "(nobranch)" respectively.
-        if ((strpos($branches[0], '(detachedfrom') === 0) || ($branches[0] === '(nobranch)')) {
+        if ((strpos($branches[0], '(detachedfrom') === 0)
+            || (strpos($branches[0], '(HEADdetachedat') === 0)
+            || ($branches[0] === '(nobranch)')) {
             $branches = array_slice($branches, 1);
         }
 
@@ -264,7 +266,9 @@ public function getCurrentBranch()
 
         foreach ($branches as $branch) {
             if ($branch[0] === '*') {
-                if ((strpos($branch, '* (detached from ') === 0) || ($branch === '* (no branch)')) {
+                if ((strpos($branch, '* (detached from ') === 0)
+                    || (strpos($branch, '* (HEAD detached at ') === 0)
+                    || ($branch === '* (no branch)')) {
                     return NULL;
                 }
 
diff --git a/tests/Gitter/Tests/RepositoryTest.php b/tests/Gitter/Tests/RepositoryTest.php
index cc6e7ef..312d041 100755
--- a/tests/Gitter/Tests/RepositoryTest.php
+++ b/tests/Gitter/Tests/RepositoryTest.php
@@ -176,13 +176,13 @@ public function testIsGettingCurrentBranch()
     {
         $repository = $this->client->getRepository(self::$tmpdir . '/testrepo');
         $branch = $repository->getCurrentBranch();
-        $this->assertTrue($branch === 'master');
+        $this->assertEquals('master', $branch);
 
         $commits = $repository->getCommits();
         $hash = $commits[0]->getHash();
         $repository->checkout($hash);
         $new_branch = $repository->getCurrentBranch();
-        $this->assertTrue($new_branch === NULL);
+        $this->assertNull($new_branch);
 
         $repository->checkout($branch);
     }
@@ -195,7 +195,7 @@ public function testIsGettingBranchesWhenHeadIsDetached()
         $hash = $commits[0]->getHash();
         $repository->checkout($hash);
         $branches = $repository->getBranches();
-        $this->assertTrue(count($branches) === 3);
+        $this->assertEquals(3, count($branches), print_r($branches, true));
 
         $branch = $repository->getHead('develop');
         $repository->checkout($current_branch);