Browse Source

update sychronisation scripts

julien colomb 2 years ago
parent
commit
9d5b859a60
5 changed files with 82 additions and 24 deletions
  1. 5 5
      .scripts/GIN-sync
  2. 29 0
      .scripts/setginserver
  3. 19 11
      .scripts/template_init.command
  4. 28 7
      INIT-sync
  5. 1 1
      sync.bat

+ 5 - 5
.scripts/GIN-sync

@@ -67,15 +67,15 @@ else
 fi
 
 echo "intialise submodules"
-git submodule foreach gin init
+gin git submodule foreach gin init
 
 echo "Synchronising submodules"
-git submodule foreach gin commit . -m "$commitmessage"
+gin git submodule foreach gin commit . -m "$commitmessage"
 checkerror $? "Error occurred during 'gin commit'"
-git submodule foreach gin sync
+gin git submodule foreach gin sync
 checkerror $? "Error occurred during 'gin sync'"
 
-git submodule foreach gin upload
+gin git submodule foreach gin upload
 checkerror $? "Error occurred during 'gin upload'"
 
 ## remove uploaded (annexed) content
@@ -92,7 +92,7 @@ if [[ "${syncopt}" == "download" ]]; then
 
 echo "Synchronising main repository"
 
-gin commit . -m "$commitmessage"
+gin git commit . -m "$commitmessage"
 gin sync
 gin upload
 

+ 29 - 0
.scripts/setginserver

@@ -0,0 +1,29 @@
+# set server, use HU server
+if ! gin use-server hu; then
+  echo "set gin server"
+  # set gin remote from git information (on the hu server)
+  gin add-server --web https://gindata.biologie.hu-berlin.de:443 --git git@gindata.biologie.hu-berlin.de:10022 hu
+
+  # chose hu server for this computer
+  gin use-server hu
+
+fi
+
+
+# set remote
+if ! gin remotes; then
+  echo "set gin remote"
+  # set gin remote from git information (on the hu server)
+  remotegit=$(git remote get-url origin)
+  remotegin="$(echo "$remotegit" | cut -d'/' -f4,5)"
+
+  remotegin="$(echo $remotegin | cut -d' ' -f1)"
+  remotegin="$(echo "hu:""${remotegin/.git}")"
+  gin add-remote primary "$remotegin"
+else
+    echo gin remote set
+fi
+
+
+
+

+ 19 - 11
.scripts/template_init.command

@@ -24,15 +24,16 @@ reposhort="$(echo "${repo/.main}")"
 
 # readme text
 readmetext="$Gitadress/$Orga/$repo is the parent directory"
+gitign=".DS_Store"
 
 echo "readme will be $readmetext"
 
 echo "erase master branch and go to main if there is a main branch"
-git checkout main
-git branch -D master
+gin git checkout main
+gin git branch -D master
 
 # initialise submodules
-git submodule update --init --recursive
+gin git submodule update --init --recursive
 
 # if the template was not initialise before, let's do it
 if test -f "03_data/001_data/README_data.md" ;
@@ -42,11 +43,18 @@ else
     echo "setting up the template for the first time !"
     
     # add readme files, and folders
-    echo "$readmetext" >> 03_data/001_data/README_data.md
+    echo "$readmetext" >> 03_data/001_raw_data/README_dataraw.md
     echo "$readmetext" >> 04_data_analysis/010_code/README_analysiscode.md
     echo "$readmetext" >> 05_figures/990_shared_figures/README_figures.md
-    echo "$readmetext" >> 03_data/001_data/README_data.md
+    echo "$readmetext" >> 03_data/001_derived_data/README_dataderived.md
     echo "$readmetext" >> 06_dissemination/README_DISSEMINATION.md
+    
+    echo "$gitign" >> 03_data/001_raw_data/.gitignore
+    echo "$gitign" >> 04_data_analysis/010_code/.gitignore
+    echo "$gitign" >> 05_figures/990_shared_figures/.gitignore
+    echo "$gitign" >> 03_data/001_derived_data/.gitignore
+    echo "$gitign" >> 06_dissemination/.gitignore
+    
     mkdir 06_dissemination/01_reports_conferences
     mkdir 06_dissemination/02_manuscripts
     mkdir 06_dissemination/03_other
@@ -55,12 +63,12 @@ else
     touch 06_dissemination/03_other/.gitkeep
     
     # add labcommons submodule
-    git submodule add "../labcommons" 07_misc/labcommons
+    gin git submodule add "../labcommons" 07_misc/labcommons
     
     # push submodule content
-    git submodule foreach gin init
-    git submodule foreach gin commit . -m initial commit from template
-    git submodule foreach gin upload
+    gin git submodule foreach gin init
+    gin git submodule foreach gin commit . -m initial commit from template
+    gin git submodule foreach gin upload
     
     # delete file telling the initialisation need to be done
     rm "00repo_needs_initialisation00.txt"
@@ -80,8 +88,8 @@ else
     
     # add 2 submodule for figures and dissemination files there
     
-    git submodule add "../$reposhort.05_figures_990_shared_figures.git" ""$reposhort"/05_figures/990_shared_figures"
-    git submodule add "../$reposhort.06_dissemination" ""$reposhort"/06_dissemination"
+    gin git submodule add "../$reposhort.05_figures_990_shared_figures.git" ""$reposhort"/05_figures/990_shared_figures"
+    gin git submodule add "../$reposhort.06_dissemination" ""$reposhort"/06_dissemination"
     
     # add a file to tell the user/script to initialise the submodules next time.
     

+ 28 - 7
SSH-INIT-SYNC → INIT-sync

@@ -18,6 +18,21 @@ projectdir=$(git -C ${loc} rev-parse --show-toplevel)
 
 pushd ${loc} > /dev/null
 
+## set gin server and remote
+if ! gin remotes; then
+  sh .script/setginserver
+else
+    echo gin remote set
+fi
+
+#login if needed
+if ! gin info; then
+  echo "set gin login"
+  gin login
+else
+    echo "gin logged"
+fi
+
 ## code 1
 if test -f "00repo_needs_initialisation00.txt" ;
   then
@@ -26,16 +41,22 @@ if test -f "00repo_needs_initialisation00.txt" ;
 fi
 
 ## code 2
- 
-if  (test -f "06_dissemination/README_DISSEMINATION.md") ;
+
+if grep -q 06_dissemination ".gitmodules"; 
   then
-  echo "submodules are initialised"
+  if  (test -f "06_dissemination/README_DISSEMINATION.md") ;
+    then
+    echo "submodules are initialised"
 
+    else
+    echo "initialising submodules"
+    gin git submodule update --init --recursive
+    gin git submodule foreach gin init
+    fi
   else
-  echo "initialising submodules"
-  git submodule update --init --recursive
-  git submodule foreach gin init
-fi
+  echo "not a tonic repo, please initialise submodules manually if there are any"
+fi 
+
 
 ## code 3
 

+ 1 - 1
sync.bat

@@ -2,6 +2,6 @@
 
 set curdir=%~dp0
 
-C:\cygwin64\bin\bash -l %curdir%GIN-sync.sh
+C:\cygwin64\bin\bash -l %curdir%INIT-sync
 
 pause