Skip to content

Commit dc05924

Browse files
committed
added GitRepo::git_directory_path()
the new git_directory_path method returns the path to the ".git" directory in the case of a normal directory, or the repo path in the case of a bare repo. also changed the get_description() and set_description() methods to use this new method.
1 parent 9b24305 commit dc05924

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

Git.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,16 @@ public function set_repo_path($repo_path, $create_new = false, $_init = true) {
228228
}
229229
}
230230
}
231+
232+
/**
233+
* Get the path to the git repo directory (eg. the ".git" directory)
234+
*
235+
* @access public
236+
* @return string
237+
*/
238+
public function git_directory_path() {
239+
return ($this->bare) ? $this->repo_path : $this->repo_path."/.git";
240+
}
231241

232242
/**
233243
* Tests if git is installed
@@ -640,11 +650,7 @@ public function log($format = null) {
640650
* @param string $new
641651
*/
642652
public function set_description($new) {
643-
if ($this->bare) {
644-
$path = $this->repo_path;
645-
} else {
646-
$path = $this->repo_path."/.git";
647-
}
653+
$path = $this->git_directory_path();
648654
file_put_contents($path."/description", $new);
649655
}
650656

@@ -654,11 +660,7 @@ public function set_description($new) {
654660
* @return string
655661
*/
656662
public function get_description() {
657-
if ($this->bare) {
658-
$path = $this->repo_path;
659-
} else {
660-
$path = $this->repo_path."/.git";
661-
}
663+
$path = $this->git_directory_path();
662664
return file_get_contents($path."/description");
663665
}
664666

0 commit comments

Comments
 (0)