| | 20 | # WINDOWS: sample of pre-commit.bat (must use temporary files for the log message) |
| | 21 | # |
| | 22 | ##SET REPOS=%1 |
| | 23 | ##SET TXN=%2 |
| | 24 | ## |
| | 25 | ##::----------------------------- |
| | 26 | ##::Call the TRAC pre-commit hook |
| | 27 | ##:: |
| | 28 | ##SET TRAC_ENV=C:\somewhere\trac\project |
| | 29 | ##SET LOG_FILE=%TEMP%.\svnfileT-%TXN% |
| | 30 | ## |
| | 31 | ##svnlook log -t %TXN% %REPOS%>%LOG_FILE% |
| | 32 | ## |
| | 33 | ##python [trac-path]\contrib\trac-pre-commit-hook "%TRAC_ENV%" "file:%LOG_FILE%" |
| | 34 | ##IF ERRORLEVEL 1 SET TRAC_CANCEL=YES |
| | 35 | ##DEL %LOG_FILE% |
| | 36 | ##IF DEFINED TRAC_CANCEL GOTO :ERROR |
| | 37 | ##:: |
| | 38 | ##::----------------------------- |
| | 39 | ## |
| | 40 | ##:SUCCESS |
| | 41 | ##EXIT 0 |
| | 42 | ## |
| | 43 | ##:ERROR |
| | 44 | ##EXIT 1 |
| | 45 | ## |
| | 46 | |
| | 86 | def _readFromFile(message): |
| | 87 | """ Ivan Melnychuk: SOLUTION FOR WINDOWS SYSTEMS: |
| | 88 | Windows does not support returning values from script. |
| | 89 | Therefore temporary files may be used to keep some information like commit message |
| | 90 | If the 'message' starts with 'file:', and the file with indicated name exists, then read the text message from the file rather then using the text directly |
| | 91 | Even though actual message also may start with such prefix, it is very unlikely that the file exists with such a name by accident |
| | 92 | """ |
| | 93 | if message[:5] == 'file:' and os.path.exists( message[5:] ): |
| | 94 | f = open( message[5:], 'r' ) |
| | 95 | message = f.read() |
| | 96 | f.close() |
| | 97 | return message |
| | 98 | return message; |
| | 99 | |