下面是我的提交消息的鉤子,它適用於手動完成的所有合併和提交。當我嘗試用底墊中使用它,它停止說如何檢查rebase提交鉤子?
「這個分支僅用於合併提交,不能直接在這裏提交的代碼」。
它直接將代碼提交到默認值。這不是合併嗎?
需要掛鉤的是避免任何直接提交到默認分支,並承諾只應做的特性分支(default之外的其他分支)。另外,如果分支中沒有遵循適當的命名約定,它將會失敗。
請讓我知道如何允許rebase提交或如果我錯過了鉤子上的任何東西?
import re
def commitmessage(ui, repo, *args, **kwargs):
changectx = repo[kwargs['node']]
if changectx.branch() == 'default' :
if kwargs['parent2'] == '':
if changectx.rev() == 0:
return 0
tagsfilepresent = 0
totalfiles = 0
for aFile in changectx.files():
totalfiles = totalfiles + 1
if aFile == '.hgtags':
tagsfilepresent = 1
if totalfiles == 1 and tagsfilepresent == 1:
return 0
ui.write(changectx.branch() + ' This branch is only for Merge Commits, cannot commit the code directly here\n\n')
return 1
secondarybranchname = repo[kwargs['parent2']].branch()
ui.write('Merging ' + secondarybranchname + ' to default\n')
ui.write('Merge Commit Successful to default for ticket: ' + secondarybranchname[1:] + '\n')
return 0
m = re.match('^t(\d{4,5})$', changectx.branch())
if m:
ui.write('Commit Successful to ' + m.group(1) + '\n')
return 0
else:
ui.write('Branch name is not Acceptable, it should be either default or t(numeric)\n')
return 1
ui.write('If you think this special case is not handled here, please notify' + '\n')
return 1