{"id":2451,"date":"2018-03-31T15:15:26","date_gmt":"2018-03-31T20:15:26","guid":{"rendered":"http:\/\/osric.com\/chris\/accidental-developer\/?p=2451"},"modified":"2018-03-31T15:15:26","modified_gmt":"2018-03-31T20:15:26","slug":"make-a-cvs-project-read-only","status":"publish","type":"post","link":"https:\/\/osric.com\/chris\/accidental-developer\/2018\/03\/make-a-cvs-project-read-only\/","title":{"rendered":"Make a CVS project read-only"},"content":{"rendered":"<p>In the previous post, <a href=\"https:\/\/osric.com\/chris\/accidental-developer\/2018\/03\/converting-cvs-to-git-repository\/\">Converting a CVS project to a Git repository<\/a>, I describe using cvs2git to convert a CVS project to a git repository. After I made the conversion, I wanted to make the CVS project read-only.<\/p>\n<p>There&#8217;s probably no reason to keep the CVS project around (the history is in the git repo, and I have backups of the CVS project), but it felt like the right thing to do. The blog post <a href=\"https:\/\/blog.christopherschultz.net\/index.php\/2012\/06\/15\/read-only-cvs-access-for-only-certain-projects\/\">Read-only CVS access for only certain projects<\/a> was extremely helpful to accomplish this.<\/p>\n<p>The key component is the <code>CVSROOT\/commitinfo<\/code> file within your CVS repository. Like any other project in CVS, you need to check this out to make changes:<\/p>\n<pre><code>cvs co CVSROOT\r\ncd CVSROOT &amp;&amp; vi commitinfo<\/code><\/pre>\n<p>You specify a regular expression and a script to run before committing data to a project matching that regular expression. If the script exits with a non-zero exit code (indicating an error), the commit is aborted. For initial testing, I used <code>false<\/code> (or <code>\/bin\/false<\/code>) for the script component, which does nothing and returns an exit code of 1.<\/p>\n<p>I had some problems with this, in part because I was not sure what the project string would look like. I tried a few things:<\/p>\n<ul>\n<li><code>^\/testrepo\/.* false<\/code> (didn&#8217;t work)<\/li>\n<li><code>^testrepo\/.* false<\/code> didn&#8217;t work<\/li>\n<li><code>^t.* false<\/code> worked, but would match other projects as well<\/li>\n<\/ul>\n<p>Eventually I switched to using the <code>read-only-project.sh<\/code> example from the aforementioned blog post, which printed out the values of the project path and the filenames to be committed.<\/p>\n<p>From there I could see that the project path:<\/p>\n<ul>\n<li>Does not include an initial slash<\/li>\n<li>Does not include a trailing slash<\/li>\n<li>May include additional slashes if the project contains subdirectories<\/li>\n<\/ul>\n<p>The same script suggests including the following in commitinfo:<\/p>\n<pre><code>^projectname\/.* \/path\/to\/script \"%p\" %s<\/code><\/pre>\n<p>That regular expression does not work &#8212; it would match a file at projectname\/subdir1\/file1 but not projectname\/file1.<\/p>\n<p>And what do the &#8220;%p&#8221; and %s mean? From <a href=\"http:\/\/cvsman.com\/cvs-1.12.12\/cvs_189.php\">C.3.4 Commitinfo<\/a>: <\/p>\n<blockquote><p>Currently, if no format strings are specified, a default string of ` %r\/%p %{s}&#8217; will be appended to the command line template before replacement is performed, but this feature is deprecated.<\/p><\/blockquote>\n<p>I found another document, <a href=\"http:\/\/cvsman.com\/cvs-1.12.12\/cvs_185.php#SEC185\">C.3.1 The common syntax<\/a>, which describes the format strings. <\/p>\n<ul>\n<li><code>p<\/code> &#8211; the name of the directory being operated on within the repository.<\/li>\n<li><code>{s}<\/code> &#8211; the file name(s), in curly braces because it is a list<\/li>\n<\/ul>\n<p>The same page includes a sample regular expression that solves the problem I was having:<\/p>\n<pre><code>^module\\(\/\\|$\\)<\/code><\/pre>\n<p>Finally, here is what I added to <code>CVSROOT\/commitinfo<\/code>:<\/p>\n<pre><code>^testrepo\\(\/\\|$\\) \/usr\/local\/script\/read-only-project.sh<\/code><\/pre>\n<p>Note that this script needs to exist on the same machine as the CVS repository (which may or may not be the same machine as your checked-out copy).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can use the CVSROOT\/commitinfo file to run scripts before any commits to CVS projects matching a regular expression. I used this to make a CVS project read-only after moving it into Git.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[232],"tags":[4],"class_list":["post-2451","post","type-post","status-publish","format-standard","hentry","category-tips-tricks","tag-cvs"],"_links":{"self":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/2451","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/comments?post=2451"}],"version-history":[{"count":2,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/2451\/revisions"}],"predecessor-version":[{"id":2455,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/2451\/revisions\/2455"}],"wp:attachment":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/media?parent=2451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/categories?post=2451"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/tags?post=2451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}