now that we force projects to have the right value for the Repository field (http://drupal.org/node/59504), and now that we force projects to have exactly 1 term from the top-level project taxonomy (http://drupal.org/node/64221) we can now do a better job validating the "CVS directory" field on the project node. at the very least, we can ensure that the first two parts of the path match the repository and directory corresponding to the top-level taxonomy term they selected. a lot of people seem to get this wrong, and that adds to the confusion/trouble people sometimes have with the CVS access stuff. this change should be pretty easy. i'll work on a patch.

Comments

dww’s picture

Priority: Normal » Critical
Status: Active » Needs review
StatusFileSize
new4.53 KB

well, we don't need to match the repo for anything, since that's not part of the "CVS directory" path we're looking for. however, we definitely want the 1st part of the path to match the selected project type, and the last part of the path to match the "Project short name". really, the directory should match what's in CVS and the short name should match the directory, but string comparisons are good enough for now to catch the kinds of errors i was talking about in http://drupal.org/node/67941 (duplicate of this). since drupal.org doesn't run on the same filesystem as cvs.drupal.org, there's no good way for the cvs.module to automatically check if the directory really exists.

so, here's a patch to address both of these things. each behavior is controlled by another checkbox in the admin/settings/cvs page (they default to yes). also, projects in the "Projects that can select their CVS repository:" list are excluded from this additional validation (so that the drupal core project with '/' as the cvs directory doesn't have problems).

heavily tested on a local site with all kinds of combinations.

unfortunately, chx tells me there's no way for a single form_set_error() to light-up 2 fields that aren't children of the same parent, so i had to use 2 calls to get both the short name and the cvs directory marked as an error when they don't match.

while i was at it, i fixed a minor pet peave of mine:

- form_set_error('cvs_directory', t('The path of the CVS directory should end with a leading slash.'));
+ form_set_error('cvs_directory', t('The path of the CVS directory should end with a trailing slash.'));

it's not "leading" if it's at the end. ;)

anyway, is this RTBC? this will definitely help with the crappy errors that result when all of these things aren't setup just right (i could paste a bunch of issue links in here as examples, but i think we all get the idea).

thanks,
-derek

AjK’s picture

Patch applied and tested. Does what it says on the tin :)

Only point I would say is that, when the shortname doesn't match the trailing directory name you get two errors :-

  • The last part of the CVS directory (wrong) does not match the short project name (test23).
  • The short project name (test23) does not match the last part of the CVS directory (wrong).

I believe there's one error here and not two. But which to highlight? I'd say the directory is wrong and highlight that as the error field. I suppose the description text "This will be used to generate a /project// URL for your project." could be made red to draw attention to the close association of the two textfields ?

Anyway, it does pass the test of doing what Derek intended.

regards
--AjK

dww’s picture

yeah, as i said:

unfortunately, chx tells me there's no way for a single form_set_error() to light-up 2 fields that aren't children of the same parent, so i had to use 2 calls to get both the short name and the cvs directory marked as an error when they don't match

yes, it's really 1 error, but either field might be wrong. in fact, more often then not, if they don't match, i'd guess that the short name was the one that'll need changing, while the directory name in cvs will be ok. that's why i decided to just print 2 (symetric) errors.

we probably could clarify the description of the shortname field when cvslog is installed to make it clear it must also match the directory name in cvs. i think that'd be easy in form_alter(), too. i may even roll a new patch for that, but i think it'd be ok to commit this one as-is for now.

AjK’s picture

Agreed, I'd also sat RTBC

regards
--AjK

gerhard killesreiter’s picture

Status: Needs review » Reviewed & tested by the community

looks good to me.

dww’s picture

Status: Reviewed & tested by the community » Fixed

applied to HEAD + 4.7.

dww’s picture

Status: Fixed » Needs review
StatusFileSize
new2.5 KB

whoops, i forgot that the project taxonomy terms on d.o are upper cased.

dww’s picture

Status: Needs review » Fixed

applied to head + 4.7

dww’s picture

Status: Fixed » Needs review
StatusFileSize
new2.63 KB

ugh, still broken. :( i forgot about "Theme engines" -> "theme-engines".

we considered a more flexible, general purpose UI for mapping taxonomy terms into directory paths, but killes didn't think it was worth the effort. so, this patch isn't the most generic for non drupal.org uses of cvs.module, but it's not completely insane, and it at least stops the bleeding. if someone else wants to use cvs.module somewhere else and finds this too restrictive, they can provide a patch for a more generic solution. ;)

AjK’s picture

Applied and tested. Patch looks good.

regards
--AjK

dww’s picture

Status: Needs review » Fixed

in IRC, halkeye also said this was RTBC. applied to 4.7 and HEAD.

Anonymous’s picture

Status: Fixed » Closed (fixed)