Skip to content

Commit eefe4f4

Browse files
committed
Datalad DP: works better when repo already on filesystem
1 parent 046b1a0 commit eefe4f4

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

lib/datalad_repository.rb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2121
#
2222

23-
require 'fileutils'
24-
2523
# This library handles some elementary operation on a local datalad
2624
# repository, mosly used when that repo is a cache for a DataladDataProvider.
2725
#
@@ -56,18 +54,27 @@ def install_from_url!(url, tagname=nil)
5654
tagname = tagname.presence || "" # need empty string in bash commands
5755
retcode = run_datalad_commands(parent,
5856
"
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
6165
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
6369
else
64-
git pull >/dev/null || exit 42
70+
git pull >/dev/null || exit 44
6571
fi
6672
"
6773
)
6874
cb_error "Could not run datalad install." if retcode == 41
6975
cb_error "Could not update datalad dataset." if retcode == 42
7076
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
7178
cb_error "Error occured when running datalad script: retcode=#{retcode}" if retcode > 0
7279
true
7380
end

0 commit comments

Comments
 (0)