Commit 31c7c319 authored by Baptiste CHOCOT's avatar Baptiste CHOCOT
Browse files

Add optional parameter '--sha' to actev_get_system git subcommand

parent 5da80293
......@@ -18,6 +18,7 @@ class ActevGetSystemGit(ActevCommand):
* token or t: token to access the url
* install-cli or i: install the cli to use it
* name or n: name to give to the system once it is downloaded
* sha or s: commit SHA or tag to checkout
"""
def __init__(self):
super(ActevGetSystemGit, self).__init__('git', "get_git.sh")
......@@ -40,5 +41,6 @@ class ActevGetSystemGit(ActevCommand):
type=str)
arg_parser.add_argument("-i", "--install-cli", help="install the cli to use it", action='store_true')
arg_parser.add_argument("-n", "--name", help="name to give to the system once it is downloaded")
arg_parser.add_argument("-s", "--sha", help="commit SHA or tag to checkout once the repository has been cloned")
......@@ -8,7 +8,7 @@ from diva_evaluation_cli.bin.private_src.implementation.utils.actev_cli_environm
from diva_evaluation_cli.bin.private_src.implementation.get_system.system_types_definition import system_types
def entry_point(url, system_type, location=None, user=None, password=None, token=None, install_cli=False, name=False):
def entry_point(url, system_type, location=None, user=None, password=None, token=None, tag=None, install_cli=False, name=False, sha=None):
"""Private entry point.
Downloads a credentialed, web-accessible content into src
......@@ -20,6 +20,7 @@ def entry_point(url, system_type, location=None, user=None, password=None, token
password (str, optional): Password to access the url
token (str, optional): Token to access the url
install_cli (bool, optional): Information to know wether CLI has to be installed
sha (str, optional): commit SHA or tag to checkout after cloning
"""
try:
......@@ -74,7 +75,8 @@ def entry_point(url, system_type, location=None, user=None, password=None, token
" " + password + \
" " + token + \
" " + install_cli + \
" " + name
" " + name + \
" " + sha
# execute the script
# status is the exit status code returned by the program
......
......@@ -7,6 +7,7 @@ password=$4
token=$5
cli=$6
name=$7
sha=$8
# If there are credentials
# Replace '@' by its hexa character to clean the fields to avoid confusion with the '@' delimiter
......@@ -32,9 +33,16 @@ if [ $location != "None" ];then
cd $location
fi
git clone --recursive $url $name
git clone --recursive $url
if [ $? -eq 0 ];then
# If sha or tag is specified
if [ $sha != "None" ];then
dest=`echo $end | sed 's,^.*/,,' | sed 's,\.git$,,'`
cd $dest
git checkout $sha
cd ..
fi
# If the system has to be installed
if [ $cli == "True" ];then
repo_name=`echo $url | rev | cut -d '.' -f2 | rev`
......
......@@ -21,6 +21,7 @@ Clones a git repository
| password | p | False | password to access the url |
| token | t | False | token to access the url |
| name | n | False | name to give to the system |
| sha | s | False | commit SHA or tag to checkout |
### Usage
......@@ -54,6 +55,14 @@ Store the system in a specific directory:
actev get-system git -u <git repository url> ... -l <location> -n <directory name>
```
Switching on a specific commit after cloning:
```
actev get-system git -u <url> -s <commit SHA or tag>
```
:warning: You can also use this feature with tags. However, be careful your project does not have a branch with the same name than your tag, otherwise the checkout will happen on the branch and not the tag. The correct format for tags is `--sha tags/<tag>`.
:information_source: You can also directly add your credentials inside the url.
:warning: if your password or token starts with *-* as in this example: `-9r45ijFo0`, you should write `--password=-9r45ijFo0` instead of `-p -9r45ijFo0`. Otherwise, the value will be interpreted as an argument to parse.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment