Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 489681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:49:58+00:00 2026-05-13T01:49:58+00:00

I wrote the following pre-commit script for SVN to validate that a user has

  • 0

I wrote the following pre-commit script for SVN to validate that a user has submitted the minimum amount of information on a file commit. However, when trying to add/delete a directory, now it is failing. I know why it’s failing obviously, I just didn’t realize the pre-commit script was called on every action. How do I filter for the action being performed? Can I do that with svn log or do I need to use something else?

<?php
define('SVNLOOK', "\"C:\Program Files\CollabNet\Subversion Server\svnlook.exe\"");
define('NOTEXT', 1000);
define('NOPATTERNMATCH', 1001);
define('ERRORPROCESSING', 9999);

$repo_path = $argv[1];
$transaction = $argv[2];
$tracking_regex_pattern = "/\b(?:bug|issue|ter)\s*[#]{0,1}(\d+)\b/i";

exec(SVNLOOK . " log $repo_path -t$transaction", $revisions);

//loop through transaction message line by line for validation
$validation_passed = (bool) false;
$has_text = (bool) false;
foreach($revisions as $change_line){
  $change_line = trim($change_line);
  if (!empty($change_line)){
    $has_text = true;
    if (preg_match($tracking_regex_pattern, $change_line)) {
        $validation_passed = true;
    }
  }
}

if(!$validation_passed){
  switch($has_text) {
    case true:
      throwError(NOPATTERNMATCH, $revisions);
      break;
    case false:
      throwError(NOTEXT, $revisions);      
      break;
    default:
      throwError(ERRORPROCESSING, $revisions);
      break;
  }   
}else{
  exit(0);
}

function throwError($error_code, $revisions){
  $fp = fopen('php://stderr', 'w');
  fwrite($fp, "********** (Error Code: $error_code) **********\n");
  foreach($revisions as $change_line) {
    fwrite($fp, $change_line."\n"); 
  }
  fclose($fp); 
  exit($error_code);  
}
?>

How do I test for what svn command is being exectued in the current transaction? Basically I only want the validation to run on a svn commit and not a copy, mkdir, etc…

Thanks in advance!!!

EDIT: I probably should have clarified with the original post, I am using TortoiseSVN’s Create Folder… to do this. Maybe TortoiseSVN is doing some kind of commit operation?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T01:49:59+00:00Added an answer on May 13, 2026 at 1:49 am

    I don’t have a great answer for you, but…

    Maybe you can use svnlook changed --copy-info to help a bit. Using that, you can tell if an item was copied from somewhere. If all items are copied, then it may be safe to assume this from an svn copy instruction. Likewise, if you checking the items returned, you should be able to determine if it was from adding or deleting a directory as well (since it will just be a single directory item being added or deleted.)

    Hope it helps somewhat…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 229k
  • Answers 229k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You could do something based on this answer, noting that… May 13, 2026 at 1:50 am
  • Editorial Team
    Editorial Team added an answer In T-SQL: UPDATE table SET col = col + 'B'… May 13, 2026 at 1:50 am
  • Editorial Team
    Editorial Team added an answer You can use App.Config as mentioned by astander. For our… May 13, 2026 at 1:50 am

Related Questions

I have a string that represents a non indented XML that I would like
While the C# spec does include a pre-processor and basic directives (#define, #if, etc),
I would like to take a string representation of a set and parse it.
In my website I've a php script that launches a file download without showing
we have a J2EE web application usig Spring MVC. We have a new requirement

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.