반응형
git이 오류없이 아무것도 커밋하지 않는 방법?
나는하는 패브릭 스크립트를 작성하려고 해요 git commit
; 그러나 커밋 할 내용이 없으면 git은 상태가 1
. 배포 스크립트는이를 실패로 간주하고 종료합니다. 실제 커밋 실패 를 감지하고 싶기 때문에 패브릭에 git commit
실패를 무시할 수는 없습니다 . 배포를 계속할 수 있지만 실제 커밋이 실패 할 때 발생하는 오류를 잡을 수 있도록 빈 커밋 실패를 무시하려면 어떻게해야합니까?
def commit():
local("git add -p && git commit")
git diff의 종료 코드를 확인하여이 조건을 미리 포착 하시겠습니까?
예 (셸에서) :
git add -A
git diff-index --quiet HEAD || git commit -m 'bla'
편집 : git diff
Holger의 의견에 따라 명령을 수정했습니다 .
로부터 git commit
매뉴얼 페이지
--allow-empty
Usually recording a commit that has the exact same tree as its
sole parent commit is a mistake, and the command prevents you
from making such a commit. This option bypassesthe safety, and
is primarily for use by foreign SCM interface scripts.
with settings(warn_only=True):
run('git commit ...')
이로 인해 패브릭이 실패를 무시합니다. 빈 커밋을 생성하지 않는 이점이 있습니다.
with hide('warnings'):
출력을 완전히 억제하기 위해 추가 레이어로 래핑 할 수 있습니다 . 그렇지 않으면 패브릭 출력에 커밋이 실패했다는 메모가 표시됩니다 (하지만 fabfile은 계속 실행 됨).
시도 / 잡기 아기!
from fabric.api import local
from fabric.colors import green
def commit(message='updates'):
try:
local('git add .')
local('git commit -m "' + message + '"')
local('git push')
print(green('Committed and pushed to git.', bold=False))
except:
print(green('Done committing, likely nothing new to commit.', bold=False))
참고 URL : https://stackoverflow.com/questions/8123674/how-to-git-commit-nothing-without-an-error
반응형
'Nice programing' 카테고리의 다른 글
Celery-현재 작업에 대한 작업 ID 가져 오기 (0) | 2020.10.31 |
---|---|
해시가없는 자바 스크립트 창 위치 href? (0) | 2020.10.31 |
Postgres 테이블에 DataFrame을 작성하는 방법은 무엇입니까? (0) | 2020.10.31 |
Git 오류 : "올바른 액세스 권한이 있고 저장소가 있는지 확인하십시오." (0) | 2020.10.31 |
subList () 사용 방법 (0) | 2020.10.31 |