Opened 12 years ago

Closed 8 years ago

#38902 closed enhancement (wontfix)

Write a pre-commit hook to prevent expanded keywords from being committed

Reported by: ryandesign (Ryan Carsten Schmidt) Owned by: admin@…
Priority: Normal Milestone:
Component: server/hosting Version:
Keywords: Cc: cooljeanius (Eric Gallager), lpsinger (Leo Singer)
Port:

Description

We should have a pre-commit hook in the Subversion repository to prevent expanded keywords from being committed. That is, if a file has svn:keywords set to "Id", it should not be possible to commit the file with contents like this:

$Id: anything $

The Subversion client is responsible for normalizing this before committing to:

$Id$

The problem is that some committers use non-standard Subversion clients like git-svn that do not respect this requirement. This could have unforeseen consequences and should be prevented.

I will work on writing this pre-commit script. It could be combined with the one needed for #12594.

Change History (13)

comment:2 Changed 12 years ago by cooljeanius (Eric Gallager)

Could this be a check done in port lint as well?

comment:3 Changed 12 years ago by cooljeanius (Eric Gallager)

Cc: egall@… added

Cc Me!

comment:4 Changed 12 years ago by lpsinger (Leo Singer)

Cc: aronnax@… added

Cc Me!

comment:5 in reply to:  2 Changed 12 years ago by larryv (Lawrence Velázquez)

Replying to egall@…:

Could this be a check done in port lint as well?

No. This is not a portfile issue; there is nothing wrong with having expanded Subversion keywords in a portfile. The problem is with the broken Subversion clients.

comment:6 Changed 12 years ago by lpsinger (Leo Singer)

Maybe we should first check if this issue is known to the git-svn developers.

comment:7 in reply to:  6 Changed 12 years ago by larryv (Lawrence Velázquez)

Replying to aronnax@…:

Maybe we should first check if this issue is known to the git-svn developers.

It must be, given that there’s that rather lengthy section in Pro Git about working around it, which you linked to on macports-dev.

comment:8 Changed 12 years ago by ecronin (Eric Cronin)

In pure git you can't do keyword substitution, but git-svn is a bridge between a local git repo and a remote svn repo and can perform translations as changes go from one to the other. Recent versions of git-svn compress the expanded keyword down to just the $Id$ marker before creating the commit object in git. It is ignored and left alone during all git operations, but then gets expanded back out properly by svn on dcommit. It's a little annoying because locally you don't have the Id info in the file so you have to use git log, but it shouldn't be causing issues with svn. I have no idea when it was added to git-svn, it's worked fine for at least a year for me. Setting the svn attributes to begin with, however, I think you still have do using a svn checkout. And I haven't found a way to turn a git mv into a svn mv that maintains history.

comment:9 Changed 12 years ago by lpsinger (Leo Singer)

ecronin, I am using git-core from MacPorts, git-core @1.8.2.1_0+bash_completion+credential_osxkeychain+doc+pcre+python27+svn. This is the latest stable release of git. Are you sure that git-svn does keyword expansion?

comment:10 Changed 12 years ago by ecronin (Eric Cronin)

It doesn't do keyword expansion in git. It just doesn't screw things up when they're pushed back to svn which is what this ticket is trying to prevent.

% which git
/opt/local/bin/git
% git svn proplist Portfile
Properties on 'Portfile':
  svn:entry:committed-date
  svn:entry:committed-rev
  svn:entry:last-author
  svn:entry:uuid
  svn:eol-style
  svn:keywords
  svn:wc:ra_dav:version-url
% git svn propget svn:keywords Portfile
Id
% head -1 Portfile
# $Id$

If I look at this Portfile in trac from svn the Id line is fully expanded. I checked my global .gitconfig and my macports/.git directory and I don't see that I did any extra customization to get this behavior, but I made this checkout long ago and I don't have time to go digging at the moment.

But the link in comment:7 doesn't apply here because the authoritative repo is svn not git. In git-land there is still no keyword substitution happening, and any attempts at faking it using client hooks on commit like suggested there would just break things when it was pushed back into svn.

comment:11 Changed 12 years ago by ryandesign (Ryan Carsten Schmidt)

I don't want to completely prevent committers from using git-svn if that is what they prefer, but I do want to preserve the integrity of the data in our repository and enforce the intended operation of Subversion keywords. Having not used git much I don't know whether the pre-commit hook contemplated in this ticket will accomplish this goal. Can anyone familiar with git say for sure? Or should I write and attach the script for someone with git-svn to test?

comment:12 Changed 10 years ago by jmroot (Joshua Root)

Owner: changed from wsiegrist@… to admin@…

comment:13 Changed 8 years ago by ryandesign (Ryan Carsten Schmidt)

Resolution: wontfix
Status: newclosed

MacPorts is moving to GitHub, at which point we will no longer use svn keywords.

Note: See TracTickets for help on using tickets.