通过Shell脚本将VSS项目批量创建并且提交迁移至Gitlab
生活随笔
收集整理的這篇文章主要介紹了
通过Shell脚本将VSS项目批量创建并且提交迁移至Gitlab
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
腳本運行環境:Git Bash
系統環境:Windows 10 Pro 1709
VSS版本:Microsoft Visual SourceSafe?2005
?
我的VSS工作目錄結構如下:
D:\work\
? --vss
? ----project1
? ------src
? ------README.md
? ------ ......
? ----project2
? ------doc
? ------src
? ------README.md
? ------ ......
? ----project3
? ------ ......
?
腳本代碼:
1 #!/bin/bash 2 3 git config --global user.name "Allen" 4 git config --global user.email allen@domain.com 5 6 # Init params 7 namespace=VssProjects # Group Name 8 namespaceId=10 # Group Id 9 rootPath=/d/work/vss # VSS work path 10 index=0 11 folderList=[] 12 13 # Each folders 14 cd $rootPath 15 for i in $(ls $rootPath) 16 do 17 echo $index $i 18 folderList[index]=$i 19 index=`expr $index + 1` 20 done 21 22 # Print folders length 23 echo ${#folderList[@]} 24 25 # Git Init 26 for dirName in ${folderList[*]} 27 do 28 workPath=$rootPath/$dirName #項目工作目錄 29 projectName=$dirName # 項目名稱 30 data='{"name":"replacement","visibility":"private","namespace_id":namespaceId,"path":"replacement"}' # 待提交的JSON數據 31 postData=${data//replacement/$projectName} # 全部替換 32 postData=${data/namespaceId/$namespaceId} # 只替換一次 33 echo $postData 34 35 # Gitlab Create Projects 36 curl --header "Private-Token: your private token" \ 37 -H "Accept: application/json" \ 38 -H "Content-type: application/json" \ 39 -X POST \ 40 -d $postData \ 41 http://git.domain.com/api/v4/projects 42 43 # Git repository init & push 44 cd $workPath 45 git init 46 git remote add origin http://username:password@domain.com/$namespace/$projectName.git 47 touch README.md 48 git add README.md 49 git add . 50 git commit -m "Init version" 51 git push -u origin master 52 done
?
轉載于:https://www.cnblogs.com/VAllen/p/Use-Shell-script-to-migrate-VSS-to-Gitlab-in-Git-Bash.html
總結
以上是生活随笔為你收集整理的通过Shell脚本将VSS项目批量创建并且提交迁移至Gitlab的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 干扰素多少钱啊?
- 下一篇: 《Linux命令行与shell脚本编程大