|
20 | 20 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
21 | 21 | # |
22 | 22 |
|
23 | | -require 'fileutils' |
24 | | - |
25 | 23 | # This library handles some elementary operation on a local datalad |
26 | 24 | # repository, mosly used when that repo is a cache for a DataladDataProvider. |
27 | 25 | # |
@@ -56,18 +54,27 @@ def install_from_url!(url, tagname=nil) |
56 | 54 | tagname = tagname.presence || "" # need empty string in bash commands |
57 | 55 | retcode = run_datalad_commands(parent, |
58 | 56 | " |
59 | | - datalad install -s #{url} #{basename.bash_escape} >/dev/null 2>&1 || exit 41 |
60 | | - cd #{basename.bash_escape} || exit 42 |
| 57 | + if ! test -d #{basename.bash_escape} ; then |
| 58 | + datalad install -s #{url} #{basename.bash_escape} >/dev/null 2>&1 || exit 41 |
| 59 | + else |
| 60 | + cd #{basename.bash_escape} || exit 50 |
| 61 | + datalad update >/dev/null 2>&1 || exit 42 |
| 62 | + cd .. |
| 63 | + end |
| 64 | + cd #{basename.bash_escape} || exit 50 |
61 | 65 | if test -n #{tagname.bash_escape} ; then |
62 | | - git checkout -b cb_#{tagname.bash_escape} #{tagname.bash_escape} >/dev/null || exit 43 |
| 66 | + if test \"$(git branch --show-current)\" != cb_#{tagname.bash_escape} ; then |
| 67 | + git checkout -b cb_#{tagname.bash_escape} #{tagname.bash_escape} >/dev/null || exit 43 |
| 68 | + fi |
63 | 69 | else |
64 | | - git pull >/dev/null || exit 42 |
| 70 | + git pull >/dev/null || exit 44 |
65 | 71 | fi |
66 | 72 | " |
67 | 73 | ) |
68 | 74 | cb_error "Could not run datalad install." if retcode == 41 |
69 | 75 | cb_error "Could not update datalad dataset." if retcode == 42 |
70 | 76 | cb_error "Could not checkout version #{tagname} of datalad dataset." if retcode == 43 |
| 77 | + cb_error "Could not update git repo of datalad dataset." if retcode == 44 |
71 | 78 | cb_error "Error occured when running datalad script: retcode=#{retcode}" if retcode > 0 |
72 | 79 | true |
73 | 80 | end |
|
0 commit comments