You appear to be a bot. Output may be restricted
Description
Check directory is a git repositoryWe want to make sure we're in the right place. git status -s
will work if the directory is not a repo itself but is in a folder which is part of a repo We need to use "gitdir" to find the root directory of the Git repo
Usage
$string = Git::is_git( $source_dir );
Parameters
- $source_dir
- ( string ) required –
Returns
string same as $source_dir if this is a Git repoSource
File name: oik-batch/includes/class-git.phpLines:
1 to 29 of 29
public function is_git( $source_dir ) { $this->echo( "is_git: " . $source_dir . PHP_EOL ); $changed = $this->chdir( $source_dir ); if ( $changed ) { $this->source_dir = $source_dir; $cdup = $this->command( "cdup" ); //echo "CDUP: $cdup" . PHP_EOL; //$gitdir = $this->command( "gitdir" ); //echo "gitdir: $gitdir" . PHP_EOL; $changed = $this->reset_dir( $changed ); if ( $this->is_repo() ) { if ( $cdup ) { $this->echo( "Git repo is not in the root" . PHP_EOL ); $source_dir = null; }else { $this->source_dir = $source_dir; } } else { $source_dir = null; } } else { $source_dir = null; } $this->echo( "returning: " . $source_dir . PHP_EOL ); return( $source_dir ); }View on GitHub