Browse Source

change script

julien colomb 2 years ago
parent
commit
ad774072a9
5 changed files with 53 additions and 2 deletions
  1. 38 0
      .scripts/datalad_sync.py
  2. 0 2
      .scripts/template_init.command
  3. 0 0
      Sync-GIN_unix
  4. 7 0
      Sync_unix
  5. 8 0
      sync.bat

+ 38 - 0
.scripts/datalad_sync.py

@@ -0,0 +1,38 @@
+from heapq import merge
+import os
+import sys
+
+import datalad.api as dl
+
+# Set folder where script will be executed
+loc = os.path.dirname(os.path.abspath(__file__))
+print(loc)
+os.chdir(loc)
+os.chdir('../')
+#projectdir = dl.Repo(loc, create=False).get_toppath()
+
+# initialise
+if not os.path.isfile("06_dissemination/README_DISSEMINATION.md"):
+    print("running project repository initiation (first run)")
+    dl.get(".", recursive=True, get_data=False)
+    dl.update(how='merge', recursive=True)
+
+# Give info on changes
+print('results of datalad status call:')
+dl.status(recursive=True, eval_subdataset_state ='commit', result_renderer ='tailored')
+
+# Set commit message
+commitmessage = input("Optionally enter a commit message, and hit return: ")
+if not commitmessage:
+    print("using date as commit message")
+    commitmessage = "commit on" + {datetime.now().strftime('%Y-%m-%d')}
+
+# sync
+dl.update(how='merge', recursive=True)
+dl.save(".", message=commitmessage, recursive=True)
+dl.push(".", to="origin", recursive=True)
+
+# Set dropping option
+q_answer = input("Do you want to drop all files that were uploaded, they will be on the server but not on this computer anymore ? [y/n]")
+if q_answer == "y":
+    dl.drop(".", recursive=True)

+ 0 - 2
.scripts/template_init.command

@@ -34,7 +34,6 @@ gin git branch -D master
 
 # initialise submodules
 gin git submodule update --init --recursive
-git submodule update --recursive --remote
 
 # if the template was not initialise before, let's do it
 # new tonic version do that, so this should be obsolete.
@@ -80,7 +79,6 @@ else
 fi
 
 if test -f "00repo_needs_initialisation00.txt" ;
-then
 
     # delete file telling the initialisation need to be done
     rm "00repo_needs_initialisation00.txt"

+ 0 - 0
INIT-sync → Sync-GIN_unix


+ 7 - 0
Sync_unix

@@ -0,0 +1,7 @@
+# Set folder where script will be executed 
+loc=$(dirname $0)
+projectdir=$(git -C ${loc} rev-parse --show-toplevel)
+
+pushd ${loc} > /dev/null
+
+python3 .scripts/datalad_sync.py

+ 8 - 0
sync.bat

@@ -0,0 +1,8 @@
+:: this script should run the sync bash script on windows, once cygwin has been installed
+
+set curdir=%~dp0
+
+python .scripts/datalad_sync.py
+
+
+pause