Skip to content

Commit

Permalink
Datalad DP: works better when repo already on filesystem
Browse files Browse the repository at this point in the history
  • Loading branch information
prioux committed Sep 9, 2024
1 parent 046b1a0 commit 1ee9825
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/datalad_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

require 'fileutils'

# This library handles some elementary operation on a local datalad
# repository, mosly used when that repo is a cache for a DataladDataProvider.
#
Expand Down Expand Up @@ -56,18 +54,27 @@ def install_from_url!(url, tagname=nil)
tagname = tagname.presence || "" # need empty string in bash commands
retcode = run_datalad_commands(parent,
"
datalad install -s #{url} #{basename.bash_escape} >/dev/null 2>&1 || exit 41
cd #{basename.bash_escape} || exit 42
if ! test -d #{basename.bash_escape} ; then
datalad install -s #{url} #{basename.bash_escape} >/dev/null 2>&1 || exit 41
else
cd #{basename.bash_escape} || exit 50
datalad update >/dev/null 2>&1 || exit 42
cd ..
fi
cd #{basename.bash_escape} || exit 50
if test -n #{tagname.bash_escape} ; then
git checkout -b cb_#{tagname.bash_escape} #{tagname.bash_escape} >/dev/null || exit 43
if test \"$(git branch --show-current)\" != cb_#{tagname.bash_escape} ; then
git checkout -b cb_#{tagname.bash_escape} #{tagname.bash_escape} >/dev/null || exit 43
fi
else
git pull >/dev/null || exit 42
git pull >/dev/null || exit 44
fi
"
)
cb_error "Could not run datalad install." if retcode == 41
cb_error "Could not update datalad dataset." if retcode == 42
cb_error "Could not checkout version #{tagname} of datalad dataset." if retcode == 43
cb_error "Could not update git repo of datalad dataset." if retcode == 44
cb_error "Error occured when running datalad script: retcode=#{retcode}" if retcode > 0
true
end
Expand Down

0 comments on commit 1ee9825

Please sign in to comment.