論崇高文本Package Control問題:如何正確調用符號鏈接的git子模塊?
我找出是什麼原因導致這個錯誤。我有包All Autocomplete
觸發它。然後我去了文件夾Packages/All Autocomplete
,並注意到它是一個git repo synlinked。然後我刪除.git
文件,指向gitdir: ../.git/modules/All Autocomplete
並recloned存儲庫,因此它的文件在回購站內。然後,程序包控件停止拋出包All Autocomplete
的錯誤,並開始爲下一個也是git子模塊並且.git
與父git文件夾同步的包執行相同的錯誤。
這是因爲All Autocomplete
是一個子模塊,因此它的控釋片文件是:
gitdir: ../.git/modules/All Autocomplete
現在你可以複製它,但你需要:
- 要使你的Packages文件夾成爲一個git存儲庫,並將
All Autocomplete
作爲子模塊添加。 - 刪除它,並安裝有
git clone --recursive
克隆你Package
文件夾回購這將創建All Autocomplete
作爲一個git子模塊,並在其上存儲文件父git的文件夾:
gitdir: ../.git/modules/All Autocomplete
我打電話的Git子模塊此子symliked:
我沒有使用Python解釋了一些測試,它與proc = subprocess.Popen()
一個問題:
>>> import os
>>> import subprocess
>>> startupinfo = subprocess.STARTUPINFO();startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW;
>>> proc = subprocess.Popen(['C:/Program Files (x86)/Git/bin/git.exe', 'symbolic-ref', '-q', 'HEAD'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, startupinfo=startupinfo, cwd='D:/SublimeText/Data/Packages/amxmodx', env=os.environ)
>>> proc.communicate()
(b'', None)
>>> proc = subprocess.Popen(['C:/Program Files (x86)/Git/bin/git.exe', 'symbolic-ref', '-q', 'HEAD'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, startupinfo=startupinfo, cwd='D:/SublimeText/Data/Packages/All Autocomplete', env=os.environ)
>>> proc.communicate()
(b'refs/heads/master\n', None)
>>>
在第一個命令,我做它有.git
文件符號鏈接到gitdir: ../.git/modules/amxmodx
包amxmodx
。我們得到了輸出(b'', None)
。
在第二個命令中,我使用All Autocomplete
包,其中包含.git
文件夾,因爲我只是將它克隆爲git子模塊。因此,由於它的安裝不是git clone --recursive
,.git
是 的一個文件夾,而且不是符號鏈接到gitdir: ../.git/modules/
,所以它有實際的git文件內容。
因此,我們得到了輸出(b'refs/heads/master\n', None)
,它正常工作並使包控件不會拋出錯誤。
如何撥打電話與subprocess.Popen()
一個符號鏈接git的子模塊,以不向符號鏈接gitdir: ../.git/modules/
產生的符號鏈接子模塊的輸出(b'refs/heads/master\n', None)
,而不是(b'', None)
一個git子模塊的調用正常工作?
我的系統信息/版本:
$ git --version
git version 2.13.0.windows.1
$ systeminfo | findstr /B /C:"OS Version"
OS Version: 10.0.15063 N/A Build 15063
$ python --version
Python 3.6.1 :: Anaconda 4.4.0 (32-bit)
更新
我使用os.system
也試過:
>>> cur_dir = os.getcwd()
>>> os.chdir(r'D:/SublimeText/Data/Packages/All Autocomplete')
>>> os.getcwd()
'D:\\SublimeText\\Data\\Packages\\All Autocomplete'
>>> os.system(r'"C:/Program Files (x86)/Git/bin/git.exe" symbolic-ref -q HEAD')
refs/heads/master
0
>>> os.chdir(r'D:/SublimeText/Data/Packages/amxmodx')
>>> os.system(r'"C:/Program Files (x86)/Git/bin/git.exe" symbolic-ref -q HEAD')
1
>>>
我也開了一個問題,這對windows的git: