Skonfigurowałem repozytorium pochodzenia git o nazwie project_name/.git.
ssh to the server, (entering ssh passwords or passphrases as I go)
mkdir project_name
cd project_name
git init
touch fabfile.py
git add fabfile.py
git commit -a -m "almost empty"
git checkout -b web
Zostawiam sieć oddziałów wyrejestrowany. Powrót do komputera lokalnego.
Wyciągam z serwera za pomocą programu klonującego i dodajemy zawartość katalogu projektu do wzorca głównego w lokalnym repozytorium. Stll nie używa tkaniny, po prostu konfiguruje, chociaż te kroki mogą być zautomatyzowane, jak przypuszczam, i żaden z nich nie potrzebuje kolejnego hasła ssh.
cd /path/to/project_name/..
git clone ssh://[email protected]_server.com/var/web/project_name/.git
cd project_name
gvim fabfile.py
git add fabfile.py
git commit -a -m "fabfile edits"
Teraz zacznę używać tkaniny. Poniżej jest fragmentem mojej fabfile zarządzania tagów git i oddziały:
#Usage: fab committag brpush | fab committag push | fab push | fab tag
def committag():
"""commit chgs, tag new commit, push tags to server."""
prompt('commit descr: ', 'COM_MSG', default='new stuff')
prompt('commit name: ', 'COM_NAME', default='0.0.1')
local('git commit -a -m "%(COM_MSG)s"' % env)
local('sleep 1')
local('git tag -u "John Griessen" -m "%(COM_MSG)s" %(COM_NAME)s' % env)
local('sleep 1')
local('git push origin --tags') #pushes local tags
def brpush():
"""create a new branch, default COM_NAME, then push to server."""
prompt('new branch name: ', 'BR_NAME', default= '%(COM_NAME)s' % env)
local('git checkout -b %(BR_NAME)s' % env)
local('sleep 2')
local('git checkout master')
local('git push origin --tags') #pushes local tags
local('git push --all origin') #pushes local master and branches
def push():
"""Push existing tags and changes to server."""
local('git push origin --tags') #pushes local tags
local('git push --all origin') #pushes local master and branches
def tag(): #Call this from committag()
"""create a gpg signed tag on the local git repo tag from prompted name ."""
prompt('tag descr: ', 'TAG_MSG', default='0.0.1')
prompt('tag name: ', 'TAG_NAME', default='0.0.1')
local('git tag -u "John Griessen" -m "%(TAG_MSG)s" %(TAG_NAME)s' % env)
Aby skorzystać z powyższych DEFS fabfile, po prostu wprowadzić pewne zmiany do mojego projektu dir myśleć o wiadomości apporpriate o nich, a nie:
$fab committag
i mam zmiany oznaczone i zaktualizowane na serwerze. Lub:
$fab committag brpush
i mam nowy oddział utworzony i serwer zaktualizowany.
Możliwy duplikat [Jak odpowiedzieć automatycznie podpowiada tkaniny z Pythona?] (Http://stackoverflow.com/questions/10479078/how-to-answer-to-prompts-automatically- z pytonem-tkaniną) – Breedly