mirror of
https://github.com/AdaCore/git-hooks.git
synced 2026-02-12 12:43:11 -08:00
Handle the case where the <GIT_DIR>/info/ directory is missing.
Fixes MC16-012.
This commit is contained in:
@@ -105,6 +105,20 @@ def git_attribute(commit_rev, filename, attr_name):
|
||||
if os.path.exists(BARE_REPO_ATTRIBUTES_FILE):
|
||||
os.remove(BARE_REPO_ATTRIBUTES_FILE)
|
||||
|
||||
# Also, if the directory where BARE_REPO_ATTRIBUTES_FILE is stored
|
||||
# does not exist, create it now. Git normally creates it for us
|
||||
# when creating the repository, but gerrit (a code review tool)
|
||||
# users have reported that some repositories have been missing it.
|
||||
# Not sure why, but easy to handle.
|
||||
attributes_dir = dirname(BARE_REPO_ATTRIBUTES_FILE)
|
||||
if not os.path.exists(attributes_dir):
|
||||
os.makedirs(attributes_dir)
|
||||
# Depending on how the repository is setup and the user's
|
||||
# umask, the group-write bit might not be set. Just force
|
||||
# the permissions to be read-write-execute for both owner
|
||||
# and group.
|
||||
os.chmod(attributes_dir, 0775)
|
||||
|
||||
keep_going = True
|
||||
while path:
|
||||
path = dirname(path)
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = true
|
||||
bare = true
|
||||
[hooks]
|
||||
from-domain = adacore.com
|
||||
mailinglist = git-hooks-ci@example.com
|
||||
22
testsuite/tests/MC16-012__missing_info_dir/cvs_check.py
Executable file
22
testsuite/tests/MC16-012__missing_info_dir/cvs_check.py
Executable file
@@ -0,0 +1,22 @@
|
||||
#! /usr/bin/env python
|
||||
"""A dummy cvs_check program that passes all files.
|
||||
|
||||
It also prints a trace on stdout, in order to allow us to allow us
|
||||
to verify that the script was called with the correct arguments.
|
||||
"""
|
||||
import sys
|
||||
|
||||
filename = sys.argv[1]
|
||||
|
||||
# To help with testing, print a trace containing the name of the file
|
||||
# that is being checked.
|
||||
print "cvs_check: `%s'" % filename
|
||||
|
||||
# We should never be called for file `b', because the user requested
|
||||
# that this file not have pre-commit checks run on it (via a .gitattribute
|
||||
# file). If that's the case, error out.
|
||||
|
||||
if filename.endswith('/b'):
|
||||
print "Error: Style violations detected in file: %s" % filename
|
||||
sys.exit(1)
|
||||
|
||||
BIN
testsuite/tests/MC16-012__missing_info_dir/git-repos.tar.bz2
Normal file
BIN
testsuite/tests/MC16-012__missing_info_dir/git-repos.tar.bz2
Normal file
Binary file not shown.
77
testsuite/tests/MC16-012__missing_info_dir/test.py
Normal file
77
testsuite/tests/MC16-012__missing_info_dir/test.py
Normal file
@@ -0,0 +1,77 @@
|
||||
from support import *
|
||||
|
||||
class TestRun(TestCase):
|
||||
def test_push_commit_on_master(self):
|
||||
"""Try pushing multi-file commit on master.
|
||||
"""
|
||||
cd ('%s/repo' % TEST_DIR)
|
||||
|
||||
|
||||
p = Run('git push origin master'.split())
|
||||
expected_out = """\
|
||||
remote: *** cvs_check: `trunk/repo/a'
|
||||
remote: *** cvs_check: `trunk/repo/c'
|
||||
remote: SYSLOG: cvs_check: Pre-commit checks disabled for 8b7fc7be7be2beb9648d74d72976d024f6150061 on repo (b) by repo attribute
|
||||
remote: DEBUG: Content-Type: text/plain; charset="us-ascii"
|
||||
remote: MIME-Version: 1.0
|
||||
remote: Content-Transfer-Encoding: 7bit
|
||||
remote: From: Test Suite <testsuite@adacore.com>
|
||||
remote: To: git-hooks-ci@example.com
|
||||
remote: Bcc: file-ci@gnat.com
|
||||
remote: Subject: [repo] Update all files.
|
||||
remote: X-Act-Checkin: repo
|
||||
remote: X-Git-Refname: refs/heads/master
|
||||
remote: X-Git-Oldrev: c8c2f4576c9b677b5a0217defdc163ac44484585
|
||||
remote: X-Git-Newrev: 8b4778c47abe4af16f5a72b0dc8db46814a196ef
|
||||
remote:
|
||||
remote: commit 8b4778c47abe4af16f5a72b0dc8db46814a196ef
|
||||
remote: Author: Joel Brobecker <brobecker@adacore.com>
|
||||
remote: Date: Sun Jun 10 17:17:03 2012 -0700
|
||||
remote:
|
||||
remote: Update all files.
|
||||
remote:
|
||||
remote: Diff:
|
||||
remote: ---
|
||||
remote: a | 1 +
|
||||
remote: b | 2 ++
|
||||
remote: c | 1 +
|
||||
remote: 3 files changed, 4 insertions(+)
|
||||
remote:
|
||||
remote: diff --git a/a b/a
|
||||
remote: index 73af989..1b25a6e 100644
|
||||
remote: --- a/a
|
||||
remote: +++ b/a
|
||||
remote: @@ -1,2 +1,3 @@
|
||||
remote: First file.
|
||||
remote: +-----------
|
||||
remote: Some contents.
|
||||
remote: diff --git a/b b/b
|
||||
remote: index 8dae410..8b7fc7b 100644
|
||||
remote: --- a/b
|
||||
remote: +++ b/b
|
||||
remote: @@ -1,3 +1,5 @@
|
||||
remote: Second file.
|
||||
remote: Some other contents.
|
||||
remote: A third line.
|
||||
remote: +-- A Style violation on the next line, but we've decided it's OK.
|
||||
remote: +Trailing Space at end of line.
|
||||
remote: diff --git a/c b/c
|
||||
remote: index da60479..8ffbf8d 100644
|
||||
remote: --- a/c
|
||||
remote: +++ b/c
|
||||
remote: @@ -1,4 +1,5 @@
|
||||
remote: Final file.
|
||||
remote: +-----------
|
||||
remote: Yet more contents.
|
||||
remote:
|
||||
remote: A line after some empty line.
|
||||
To ../bare/repo.git
|
||||
c8c2f45..8b4778c master -> master
|
||||
"""
|
||||
|
||||
self.assertTrue(p.status == 0, p.image)
|
||||
self.assertRunOutputEqual(p, expected_out)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
runtests()
|
||||
Reference in New Issue
Block a user