ソースを参照

Add checkout progress in svn_git_sync history mode

cere 1 ヶ月 前
コミット
8f70cd4269
1 ファイル変更28 行追加2 行削除
  1. 28 2
      svn_interact/svn_git_sync

+ 28 - 2
svn_interact/svn_git_sync

@@ -211,8 +211,34 @@ sync_wc_to_dest() {
   fi
 }
 
-echo "[$(elapsed) s] Checking out r${start_rev}..."
-svn checkout -q -r "$start_rev" "$SRC_URL" "$WC_DIR"
+checkout_with_progress() {
+  local rev="$1"
+  echo "[$(elapsed) s] Checking out r${rev}..."
+  rm -rf -- "$WC_DIR"
+  mkdir -p "$WC_DIR"
+  svn checkout -q -r "$rev" "$SRC_URL" "$WC_DIR" &
+  local co_pid=$!
+  local last_report=-1
+  while kill -0 "$co_pid" 2>/dev/null; do
+    local current=0
+    if [[ -d "$WC_DIR" ]]; then
+      current=$(find "$WC_DIR" -path "$WC_DIR/.svn" -prune -o -print | wc -l)
+    fi
+    if [[ "$current" -ne "$last_report" ]]; then
+      echo "[$(elapsed)s] Checked out $current items..."
+      last_report="$current"
+    fi
+    sleep 1
+  done
+  wait "$co_pid"
+  local final_count=0
+  if [[ -d "$WC_DIR" ]]; then
+    final_count=$(find "$WC_DIR" -path "$WC_DIR/.svn" -prune -o -print | wc -l)
+  fi
+  echo "[$(elapsed)s] Checked out $final_count items (done)"
+}
+
+checkout_with_progress "$start_rev"
 
 sync_wc_to_dest