This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
The following commit(s) were added to refs/heads/master by this push:
new f239d3b Remove very-old unused commit hooks (which use py2 syntax
also)
f239d3b is described below
commit f239d3bbb57d974d1fd200f235ba5ce90713a3fb
Author: Dave Brondsema <[email protected]>
AuthorDate: Thu Feb 25 14:18:23 2021 -0500
Remove very-old unused commit hooks (which use py2 syntax also)
---
scripts/git-hooks/for-the-remote-repo/update | 130 -----------------------
scripts/git-hooks/for-your-local-repo/commit-msg | 60 -----------
2 files changed, 190 deletions(-)
diff --git a/scripts/git-hooks/for-the-remote-repo/update
b/scripts/git-hooks/for-the-remote-repo/update
deleted file mode 100755
index b2dcc6b..0000000
--- a/scripts/git-hooks/for-the-remote-repo/update
+++ /dev/null
@@ -1,130 +0,0 @@
-#!/usr/bin/python
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-import os
-import re
-import sys
-import subprocess
-
-signoff = re.compile('^Signed-off-by: ', flags=re.MULTILINE)
-parent = re.compile('^parent ', flags=re.MULTILINE)
-no_commit = '0' * 40
-
-
-def run(*args):
- p = subprocess.Popen(list(args), stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT)
- p.wait()
- return p.stdout.readlines()
-
-
-def git_user():
- if 'GITOSIS_USER' in os.environ:
- user = os.environ['GITOSIS_USER']
- else:
- user = run('id', '-u', '-n')[0][:-1]
- if user == 'scollins':
- user = 'wolf'
- if user == 'jwh':
- prefix = 'jwh'
- else:
- prefix = user[0:2]
- return (user, prefix)
-
-
-def unwrap_commit_ids(git_output):
- return [commit_id[:-1] for commit_id in git_output]
-
-
-def all_commits_signed_off(from_rev, to_rev):
- commits = unwrap_commit_ids(
- run('git', 'rev-list', '%s..%s' % (from_rev, to_rev)))
- for commit in commits:
- raw_commit = ''.join(run('git', 'cat-file', '-p', commit))
- headers, body = raw_commit.split('\n\n', 1)
- num_parents = len(parent.findall(headers))
- if num_parents < 2 and not signoff.search(body):
- return False
- return True
-
-
-def deny_update(message):
- print message
- sys.exit(1)
-
-
-def main():
- ref_name = sys.argv[1] # the branch being updated, e.g., refs/heads/master
- # the pre-update commit-id of that branch (or '0'*40 if we're creating the
- # branch)
- old_rev = sys.argv[2]
- # the post-update commit-id of that branch (or '0'*40 if we're deleting
- # the branch)
- new_rev = sys.argv[3]
-
- (user_name, user_prefix) = git_user()
-
- if old_rev == no_commit:
- action = 'create'
- merge_base = unwrap_commit_ids(
- run('git', 'merge-base', 'master', new_rev))[0]
- # not ideal, since you probably branched off something more
- # specific than master
- elif new_rev == no_commit:
- action = 'destroy'
- else:
- action = 'update'
- merge_base = unwrap_commit_ids(
- run('git', 'merge-base', old_rev, new_rev))[0]
-
- if ref_name.startswith('refs/heads/%s/' % user_prefix) or
ref_name.startswith('refs/heads/ffa/') or user_name == 'wolf' or user_name ==
'dbrondsema':
- pass # no restrictions
- elif ref_name.startswith('refs/heads/'):
- substitutions = (user_name, ref_name, 'refs/heads/%s/*' % user_prefix)
- if action == 'create':
- deny_update(
- "You (%s) may not create '%s'; you have full rights over
'%s'." %
- substitutions)
- elif action == 'destroy':
- deny_update(
- "You (%s) may not destroy '%s'; you have full rights over
'%s'." %
- substitutions)
- elif old_rev != merge_base:
- deny_update(
- "You (%s) may not rewind or rebase '%s'; you have full rights
over '%s'." %
- substitutions)
-
- if ref_name.startswith('refs/heads/') and action != 'destroy' and not
all_commits_signed_off(merge_base, new_rev):
- deny_update('Not all commits were signed-off.')
-
-# If we were going to report via email (e.g., to a Jabber bot) we would do
something like this:
-#
-# report = run('git', 'log',
-# '--no-color',
-# '--pretty=oneline',
-# '--abbrev-commit',
-# '%s..%s' % (merge_base, new_rev))
-#
-# subject = '%s..%s FORGE %s (%s)' % (old_rev[0:7], new_rev[0:7], ref_name,
user_name)
-#
-# ...but we're not currently using that feature of the existing hook, so...
-#
-
-if __name__ == '__main__':
- main()
diff --git a/scripts/git-hooks/for-your-local-repo/commit-msg
b/scripts/git-hooks/for-your-local-repo/commit-msg
deleted file mode 100755
index 96d375b..0000000
--- a/scripts/git-hooks/for-your-local-repo/commit-msg
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/python
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-import re
-import sys
-
-signoff = re.compile('^Signed-off-by: (.*)$', flags=re.MULTILINE)
-bug = re.compile('\[(?:.*:)?#\d+\]')
-
-
-def deny_commit(message):
- print message
- sys.exit(1)
-
-
-def main():
- # argv[1] is the name of the file holding the commit message.
- # It is _not_ a commit, it has no headers. The first line is
- # the subject.
- with open(sys.argv[1]) as commit_msg:
- subject = commit_msg.readline()
-
- if not bug.search(subject):
- deny_commit('Commit subject must reference a ticket.')
-
- number_of_signoffs = 0
- signoffs = set()
- for line in commit_msg.readlines():
- match = signoff.match(line)
- # comment lines won't match signoff, so we effectively ignore them
- if match:
- number_of_signoffs += 1
- signoffs.add(match.group(1))
-
- # must be at least one sign-off
- if not len(signoffs):
- deny_commit('Commit must be signed-off.')
-
- # and every sign-off must be different
- if len(signoffs) < number_of_signoffs:
- deny_commit('Duplicate sign-offs found.')
-
-if __name__ == '__main__':
- main()