From 3bf9f94fc33da5c7701011c7a284f4e4a4e6eaee Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Wed, 18 Dec 2013 16:42:55 +0400 Subject: [PATCH] Handle the case where the /info/ directory is missing. Fixes MC16-012. --- hooks/git_attrs.py | 14 ++++ .../bare_repo_config | 7 ++ .../MC16-012__missing_info_dir/cvs_check.py | 22 +++++ .../git-repos.tar.bz2 | Bin 0 -> 4818 bytes .../tests/MC16-012__missing_info_dir/test.py | 77 ++++++++++++++++++ 5 files changed, 120 insertions(+) create mode 100644 testsuite/tests/MC16-012__missing_info_dir/bare_repo_config create mode 100755 testsuite/tests/MC16-012__missing_info_dir/cvs_check.py create mode 100644 testsuite/tests/MC16-012__missing_info_dir/git-repos.tar.bz2 create mode 100644 testsuite/tests/MC16-012__missing_info_dir/test.py diff --git a/hooks/git_attrs.py b/hooks/git_attrs.py index 811f63b..46c24f5 100644 --- a/hooks/git_attrs.py +++ b/hooks/git_attrs.py @@ -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) diff --git a/testsuite/tests/MC16-012__missing_info_dir/bare_repo_config b/testsuite/tests/MC16-012__missing_info_dir/bare_repo_config new file mode 100644 index 0000000..19e1a8f --- /dev/null +++ b/testsuite/tests/MC16-012__missing_info_dir/bare_repo_config @@ -0,0 +1,7 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = true +[hooks] + from-domain = adacore.com + mailinglist = git-hooks-ci@example.com diff --git a/testsuite/tests/MC16-012__missing_info_dir/cvs_check.py b/testsuite/tests/MC16-012__missing_info_dir/cvs_check.py new file mode 100755 index 0000000..5edc658 --- /dev/null +++ b/testsuite/tests/MC16-012__missing_info_dir/cvs_check.py @@ -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) + diff --git a/testsuite/tests/MC16-012__missing_info_dir/git-repos.tar.bz2 b/testsuite/tests/MC16-012__missing_info_dir/git-repos.tar.bz2 new file mode 100644 index 0000000000000000000000000000000000000000..2769af78e13bcdbdbe47b964ac1be50de96f02b2 GIT binary patch literal 4818 zcmZ>Y%CIzaj8qGbR0?*oVG#aM{~rmUaA4vO1g-Zq#GW|3_U-Wnr(Bx6ygI7SyA@w$ znAG%kLdeQIh8K2HQ%-bpSWlt%Fe1)e!*sY;3=GUy7%nbg zU%_xeip_z+gqOj@N+yM|2hmYpiM6I9G5{yNynQ1v1E(nb#E32$WUH(q3D-jVq77Sq-%il?L*k2p*FZfQHXO^|Pi)4`Jl%cd?DTlMht>f9~b z@hls)g)^PI;=ON1$7TtSZbuZ&aEz3N+7o%*5xp^h~dA8mIEQ z6HgRwDfg#XmjCNp_sI0XQU15T=E#UwJpK7+@BiqofX9an1w>PRMKI@lWiPwd#;&Wl zfP+(k$-mzJ+{|Yu_U%eEYdjq+e=yUEu|Z5(c*d=t_L-T5rxoU(DKLEhbGh@bHA*wM z%uMFUoQ<)_&*>K4)|r-Yjnm8PiCo7)4p&abnT-pkyePP0l2WP}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+#xY}!3Poyp%G!0>O~69_snB@9MrRB z?Ymw6D6;L|T=&=MQxCOUepA+v?H2m{)>QrB?ulA`j8fuC2N zx@oCwe`x~$=7vSlk{K6T{+#9KwSRCmBUx_UD(!pIx=L;+e`I*EHfHUodG2mri*m32 zw6|woE_hp_%)?yi>)x%;Cmm^h9q-OHUoHF4okGP!8_uq{c*gUIr;z^g*H&$RMc<2^ zyOJ3tBOLtfX1#`hOzhpS|7^TM?(DbHo+;H9P~S+nY5b}(2sEI8T!hV?<> Ygaamjk16h{>)xp}N5ex +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 +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()