GitRepo
in package
Git Repository Interface Class
This class enables the creating, reading, and manipulation of a git repository
Tags
Table of Contents
Properties
- $bare : mixed
- $envopts : mixed
- $repo_path : mixed
Methods
- __construct() : void
- Constructor
- active_branch() : string
- Returns name of active branch
- add() : string
- Runs a `git add` call
- add_tag() : string
- Add a new tag on the current position
- checkout() : string
- Runs a `git checkout` call
- clean() : string
- Runs a `git clean` call
- clone_from() : string
- Runs a `git clone` call to clone a different repository into the current repository
- clone_remote() : string
- Runs a `git clone` call to clone a remote repository into the current repository
- clone_to() : string
- Runs a `git clone` call to clone the current repository into a different directory
- commit() : string
- Runs a `git commit` call
- create_branch() : string
- Runs a `git branch` call
- create_new() : GitRepo
- Create a new git repository
- delete_branch() : string
- Runs a `git branch -[d|D]` call
- fetch() : string
- Runs a git fetch on the current branch
- get_description() : string
- Gets the project description.
- git_directory_path() : string
- Get the path to the git repo directory (eg. the ".git" directory)
- list_branches() : array<string|int, mixed>
- Runs a `git branch` call
- list_remote_branches() : array<string|int, mixed>
- Lists remote branches (using `git branch -r`).
- list_tags() : array<string|int, mixed>
- List all the available repository tags.
- log() : string
- List log entries.
- merge() : string
- Runs a `git merge` call
- pull() : string
- Pull specific branch from remote
- push() : string
- Push specific branch to a remote
- rm() : string
- Runs a `git rm` call
- run() : string
- Run a git command in the git repository
- set_description() : mixed
- Sets the project description.
- set_repo_path() : void
- Set the repository's path
- setenv() : mixed
- Sets custom environment options for calling Git
- status() : string
- Runs a 'git status' call
- test_git() : bool
- Tests if git is installed
- run_command() : string
- Run a command in the git repository
Properties
$bare
protected
mixed
$bare
= false
$envopts
protected
mixed
$envopts
= array()
$repo_path
protected
mixed
$repo_path
= null
Methods
__construct()
Constructor
public
__construct([mixed $repo_path = null ][, mixed $create_new = false ][, mixed $_init = true ]) : void
Accepts a repository path
Parameters
- $repo_path : mixed = null
- $create_new : mixed = false
- $_init : mixed = true
Tags
active_branch()
Returns name of active branch
public
active_branch([mixed $keep_asterisk = false ]) : string
Parameters
- $keep_asterisk : mixed = false
Tags
Return values
stringadd()
Runs a `git add` call
public
add([mixed $files = "*" ]) : string
Accepts a list of files to add
Parameters
- $files : mixed = "*"
Tags
Return values
stringadd_tag()
Add a new tag on the current position
public
add_tag(string $tag[, string $message = null ]) : string
Accepts the name for the tag and the message
Parameters
- $tag : string
- $message : string = null
Return values
stringcheckout()
Runs a `git checkout` call
public
checkout(mixed $branch) : string
Accepts a name for the branch
Parameters
- $branch : mixed
Tags
Return values
stringclean()
Runs a `git clean` call
public
clean([mixed $dirs = false ][, mixed $force = false ]) : string
Accepts a remove directories flag
Parameters
- $dirs : mixed = false
- $force : mixed = false
Tags
Return values
stringclone_from()
Runs a `git clone` call to clone a different repository into the current repository
public
clone_from(mixed $source) : string
Accepts a source directory
Parameters
- $source : mixed
Tags
Return values
stringclone_remote()
Runs a `git clone` call to clone a remote repository into the current repository
public
clone_remote(mixed $source, mixed $reference) : string
Accepts a source url
Parameters
- $source : mixed
- $reference : mixed
Tags
Return values
stringclone_to()
Runs a `git clone` call to clone the current repository into a different directory
public
clone_to(mixed $target) : string
Accepts a target directory
Parameters
- $target : mixed
Tags
Return values
stringcommit()
Runs a `git commit` call
public
commit([mixed $message = "" ][, mixed $commit_all = true ]) : string
Accepts a commit message string
Parameters
- $message : mixed = ""
- $commit_all : mixed = true
Tags
Return values
stringcreate_branch()
Runs a `git branch` call
public
create_branch(mixed $branch) : string
Accepts a name for the branch
Parameters
- $branch : mixed
Tags
Return values
stringcreate_new()
Create a new git repository
public
static & create_new(mixed $repo_path[, mixed $source = null ][, mixed $remote_source = false ][, mixed $reference = null ]) : GitRepo
Accepts a creation path, and, optionally, a source path
Parameters
- $repo_path : mixed
- $source : mixed = null
- $remote_source : mixed = false
- $reference : mixed = null
Tags
Return values
GitRepodelete_branch()
Runs a `git branch -[d|D]` call
public
delete_branch(mixed $branch[, mixed $force = false ]) : string
Accepts a name for the branch
Parameters
- $branch : mixed
- $force : mixed = false
Tags
Return values
stringfetch()
Runs a git fetch on the current branch
public
fetch() : string
Tags
Return values
stringget_description()
Gets the project description.
public
get_description() : string
Return values
stringgit_directory_path()
Get the path to the git repo directory (eg. the ".git" directory)
public
git_directory_path() : string
Tags
Return values
stringlist_branches()
Runs a `git branch` call
public
list_branches([mixed $keep_asterisk = false ]) : array<string|int, mixed>
Parameters
- $keep_asterisk : mixed = false
Tags
Return values
array<string|int, mixed>list_remote_branches()
Lists remote branches (using `git branch -r`).
public
list_remote_branches() : array<string|int, mixed>
Also strips out the HEAD reference (e.g. "origin/HEAD -> origin/master").
Tags
Return values
array<string|int, mixed>list_tags()
List all the available repository tags.
public
list_tags([string $pattern = null ]) : array<string|int, mixed>
Optionally, accept a shell wildcard pattern and return only tags matching it.
Parameters
- $pattern : string = null
-
Shell wildcard pattern to match tags against.
Tags
Return values
array<string|int, mixed> —Available repository tags.
log()
List log entries.
public
log([strgin $format = null ]) : string
Parameters
- $format : strgin = null
Return values
stringmerge()
Runs a `git merge` call
public
merge(string $branch) : string
Accepts a name for the branch to be merged
Parameters
- $branch : string
Tags
Return values
stringpull()
Pull specific branch from remote
public
pull(string $remote, string $branch) : string
Accepts the name of the remote and local branch
Parameters
- $remote : string
- $branch : string
Return values
stringpush()
Push specific branch to a remote
public
push(string $remote, string $branch) : string
Accepts the name of the remote and local branch
Parameters
- $remote : string
- $branch : string
Return values
stringrm()
Runs a `git rm` call
public
rm([mixed $files = "*" ][, mixed $cached = false ]) : string
Accepts a list of files to remove
Parameters
- $files : mixed = "*"
- $cached : mixed = false
Tags
Return values
stringrun()
Run a git command in the git repository
public
run(mixed $command) : string
Accepts a git command to run
Parameters
- $command : mixed
Tags
Return values
stringset_description()
Sets the project description.
public
set_description(string $new) : mixed
Parameters
- $new : string
set_repo_path()
Set the repository's path
public
set_repo_path(mixed $repo_path[, mixed $create_new = false ][, mixed $_init = true ]) : void
Accepts the repository path
Parameters
- $repo_path : mixed
- $create_new : mixed = false
- $_init : mixed = true
Tags
setenv()
Sets custom environment options for calling Git
public
setenv(mixed $key, mixed $value) : mixed
Parameters
- $key : mixed
- $value : mixed
status()
Runs a 'git status' call
public
status([mixed $html = false ]) : string
Accept a convert to HTML bool
Parameters
- $html : mixed = false
Tags
Return values
stringtest_git()
Tests if git is installed
public
test_git() : bool
Tags
Return values
boolrun_command()
Run a command in the git repository
protected
run_command(mixed $command) : string
Accepts a shell command to run
Parameters
- $command : mixed