def update(refName, oldHash, newHash, accessObject=None): """ Git Update Hook Verify that update follows telekommie rules: * Can not be master * Must be branch, not tag * If not new branch, committer name must not change >>> gitDir = "/etc/telekommie/tests/telekommie.git" >>> g = GitAccessObject(gitDir) >>> newHash = "d3bb1c687114d0c59e82ce1c9a1b423c1e0f154e" >>> Hooks.update("refs/heads/test", "0" * 40, newHash) """ if None == accessObject: accessObject = GitAccessObject(); branch = accessObject.getRef(refName) if branch.isMaster() or not branch.isBranch(): raise Hooks.Errors.RefDisallowed(refName) head = branch.getCommit() if oldHash != "0" * 40: update = accessObject.getCommit(newHash) Hooks.haveMatchingCommitterNames(head, update)