Skip to content

Commit 5c9f79f

Browse files
committed
Cleaned some code
1 parent a3f390e commit 5c9f79f

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/Gitonomy/Git/Exception/ReferenceNotFoundException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ class ReferenceNotFoundException extends \InvalidArgumentException implements Gi
1616
{
1717
public function __construct($reference)
1818
{
19-
parent::__construct(sprintf('Reference not found'));
19+
parent::__construct(sprintf('Reference not found: "%s"', $reference));
2020
}
2121
}

src/Gitonomy/Git/ReferenceBag.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public function resolveTags($hash)
168168
}
169169

170170
$tags = array();
171-
foreach ($this->references as $k => $reference) {
171+
foreach ($this->references as $reference) {
172172
if ($reference instanceof Reference\Tag && $reference->getCommitHash() === $hash) {
173173
$tags[] = $reference;
174174
}
@@ -188,14 +188,14 @@ public function resolveBranches($hash)
188188
$hash = $hash->getHash();
189189
}
190190

191-
$tags = array();
192-
foreach ($this->references as $k => $reference) {
191+
$branches = array();
192+
foreach ($this->references as $reference) {
193193
if ($reference instanceof Reference\Branch && $reference->getCommitHash() === $hash) {
194-
$tags[] = $reference;
194+
$branches[] = $reference;
195195
}
196196
}
197197

198-
return $tags;
198+
return $branches;
199199
}
200200

201201
/**

tests/Gitonomy/Git/Tests/ReferenceTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function testResolve($repository)
8989
$resolved = $repository->getReferences()->resolve($commit->getHash());
9090

9191
$this->assertEquals(1, count($resolved), "1 revision resolved");
92-
$this->assertTrue($resolved[0] instanceof Tag, "Resolved object is a tag");
92+
$this->assertTrue(reset($resolved) instanceof Tag, "Resolved object is a tag");
9393
}
9494

9595
/**
@@ -101,7 +101,7 @@ public function testResolveTags($repository)
101101
$resolved = $repository->getReferences()->resolveTags($commit->getHash());
102102

103103
$this->assertEquals(1, count($resolved), "1 revision resolved");
104-
$this->assertTrue($resolved[0] instanceof Tag, "Resolved object is a tag");
104+
$this->assertTrue(reset($resolved) instanceof Tag, "Resolved object is a tag");
105105
}
106106

107107
/**
@@ -114,7 +114,7 @@ public function testResolveBranches($repository)
114114
$resolved = $repository->getReferences()->resolveBranches($master->getCommitHash());
115115

116116
$this->assertEquals(1, count($resolved), "1 revision resolved");
117-
$this->assertTrue($resolved[0] instanceof Branch, "Resolved object is a branch");
117+
$this->assertTrue(reset($resolved) instanceof Branch, "Resolved object is a branch");
118118
}
119119

120120
/**

0 commit comments

Comments
 (0)