-1

I have SVN and Tortoise SVN installed in my machine. I have created a Batch file".bat". I am trying to get Log message to validate it that was provided in the UI before commit.

I tried this answer which was failing with following error.

svnlook: E720003: Can't open file 'C:\Users\GOPICH~1\AppData\Local\Temp\svnC891.tmp\format': The system cannot find the path specified.

Can anyone guide me what is the issue is (or) is there anyway to achieve the same.

Gopichandar
  • 2,742
  • 2
  • 24
  • 54
  • You provide repository invalid path to `svnlook` and get an error because `C:\Users\GOPICH~1\AppData\Local\Temp\svnC891.tmp\` is not a repository. – bahrep Mar 26 '18 at 14:27
  • You are working on the SVN-client, but the solution of the answer you linked operates on the SVN-server, I believe. However, you have TortoiseSVN, so you can set the property `tsvn:logminsize` to the root, so the 'OK' button in the commit dialog is grayed out unless the provided message is at least the given number of characters long... – aschipfl Mar 26 '18 at 15:17
  • @aschipfl I want to write the comment to the text file before commit. Is there a way to do that? – Gopichandar Mar 26 '18 at 15:39
  • Sorry, I can't follow. What comment do you want to write to what text file? – aschipfl Mar 26 '18 at 16:38
  • @aschipfl Comments is nothing but the "Log Message" given while committing the code. – Gopichandar Mar 27 '18 at 05:39
  • 1
    The log message is already in a file; when you have a (client-side) pre-commit hook script, its third argument is the path to that file... – aschipfl Mar 27 '18 at 08:25

1 Answers1

0

I had issues with svnlook log as it appends the \format.

Arguments returned from stderr to the commit failed dialog are known as:

path depth messagefile cwd

These arguments are printed from using the code in this answer when commit fails.

The 1st and 3rd are .tmp files located in the temp directory. (The 1st is a list of files to commit).

The 3rd argument is the message file so you can use that to check if a message is used.

@echo off
findstr . "%~3" >nul
if errorlevel 1 echo args: %* >&2 & exit 1
exit 0

This causes commit failure if message file is empty else allows the commit to succeed.

Issues:

  • Only a single space in message file causes commit failure.
  • Only a double space in message file allows commit.

Seems findstr pattern could be improved. This could be a personal preference so keeping the linked answer pattern from the question.

Idea aschipfl shared in comments:

@echo off
if %~z3 gtr 0 (exit 0) else exit 1

Any character in message file makes the file not zero in size.

AFAIK, stdout is redirected as being a hook script, thus unavailable, so @echo off is possibly not needed.

Note: Tested with SVN-client which may be why svnlook log gave me strange results. Thanks to aschipfl for the information.

michael_heath
  • 5,262
  • 2
  • 12
  • 22
  • `svnlook.exe` cannot be used on the SVN-client but on the SVN-server only. Anyway, instead of using `findstr` you could just use `if %~z3 gtr 0 (exit /B 0) else (exit /B 1)`... – aschipfl Mar 27 '18 at 08:29