Skip to content

Latest commit

 

History

History
80 lines (71 loc) · 5.05 KB

git_handling.md

File metadata and controls

80 lines (71 loc) · 5.05 KB

Documentation for the functions in git_handling.sh. A general overview is given in the project documentation.

Function documentation

If the pipes are not documented, the default is:

  • stdin: piped input ignored
  • stdout: empty

Parameters enclosed in brackets [ ] are optional.

execute_git_command_in_repository()

Param. $1repository path
$2git command (f.ex. clone, fetch, etc.)
Pipesstdoutstdout output of the executed command
Statusthe return status of the helper collection's execute_working_directory_dependant_command()

get_git_repository_remote_url()

Inspired by this SO answer

Param. $1repository path
$2name of the remote - defaults to origin (git's default) if omitted
PipesstdoutURL of remote $2 of the repository at $1
Status 0success, URL written on stdout
1path $1 doesn't exist
2path $1 is not a folder
3no read permission on path $1
4folder $1 doesn't seem to be a git repository (no ./.git folder inside)
5git config call failed
6$1 is empty

get_git_repository()

Default messages:

Status Template
0  $1 cloned to $2\n
1 Git clone error: could not clone $1 to $2\n
2 $1 already cloned to $2 - nothing to do\n
3 $2 exists and it's not a folder\n
4 $2 exists but it's not readable\n
5 $2 exist but it doesn't seem to be a git repository (no .git folder inside)\n
6 $2 exists but the attempt to run git config to get the remote URL failed\n
7 $2 exists and it's a git repository but the remote URL is not $1\n
8 Repository URL is empty\n
9 Repository path empty\n
Param. $1repository URL
$2path to clone to
[$3]stdout configuration:
  • if $3 is omitted or empty, nothing is written on stdout
  • if $3 is set to a non-empty value, the system tries to find a array variable with that name. If such a variable is defined it tries to load the element which is at the index corresponding to the return status. If either the array or the array element is not defined, it uses the default messages given above
Pipesstdoutif $3 is non-empty, the message
Status 0git clone suceeded
1git clone failed
2$1 already cloned to $2
3$2 exists but it's not a folder
4$2 is not readable
5$2 exists but it doesn't seem to be a repository
6$2 seems to be a repository but the attempt to run git config failed
7$2 exists but it has another URL than $1
8$1 emtpy
9$2 empty