Skip to content

Commit

Permalink
added GitRepo::git_directory_path()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kbjr committed Mar 23, 2015
1 parent 9b24305 commit dc05924
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions Git.php
Expand Up @@ -228,6 +228,16 @@ public function set_repo_path($repo_path, $create_new = false, $_init = true) {
}
}
}

/**
* Get the path to the git repo directory (eg. the ".git" directory)
*
* @access public
* @return string
*/
public function git_directory_path() {
return ($this->bare) ? $this->repo_path : $this->repo_path."/.git";
}

/**
* Tests if git is installed
Expand Down Expand Up @@ -640,11 +650,7 @@ public function log($format = null) {
* @param string $new
*/
public function set_description($new) {
if ($this->bare) {
$path = $this->repo_path;
} else {
$path = $this->repo_path."/.git";
}
$path = $this->git_directory_path();
file_put_contents($path."/description", $new);
}

Expand All @@ -654,11 +660,7 @@ public function set_description($new) {
* @return string
*/
public function get_description() {
if ($this->bare) {
$path = $this->repo_path;
} else {
$path = $this->repo_path."/.git";
}
$path = $this->git_directory_path();
return file_get_contents($path."/description");
}

Expand Down

0 comments on commit dc05924

Please sign in to comment.