| | 47 | # WINDOWS: sample of post-commit.bat (must use temporary files for the log message) |
| | 48 | # |
| | 49 | ##SET REPOS=%1 |
| | 50 | ##SET REV=%2 |
| | 51 | ## |
| | 52 | ##::----------------------------- |
| | 53 | ##::Call the TRAC post-commit hook |
| | 54 | ##:: |
| | 55 | ##SET TRAC_ENV=C:\somewhere\trac\project |
| | 56 | ##SET LOG_FILE=%TEMP%.\svnfileR-%REV% |
| | 57 | ##SET AUT_FILE=%TEMP%.\svnfileA-%REV% |
| | 58 | ## |
| | 59 | ##svnlook log -r %REV% %REPOS%>%LOG_FILE% |
| | 60 | ##svnlook author -r %REV% %REPOS%>%AUT_FILE% |
| | 61 | ## |
| | 62 | ##:: SET THE AUTHOR FROM THE FILE. The file is expected to contain only one line with this value |
| | 63 | ##FOR /F %%A IN (%AUT_FILE%) DO SET AUTHOR=%%A |
| | 64 | ## |
| | 65 | ##python [trac-path]\contrib\trac-post-commit-hook.py -p "%TRAC_ENV%" -r "%REV%" -u "%AUTHOR%" -m "file:%LOG_FILE%" |
| | 66 | ##DEL %LOG_FILE% |
| | 67 | ##DEL %AUT_FILE% |
| | 68 | ##:: |
| | 69 | ##::----------------------------- |
| | 70 | ## |
| | 71 | # |
| 150 | 178 | cur.execute("INSERT INTO ticket_change (ticket, time, author, field, oldvalue, newvalue) VALUES (%s, %s, %s, %s, %s, %s)", |
| 151 | 179 | int(tkt), self.now, self.author, 'comment', '', self.msg) |
| 152 | 180 | |
| | 181 | def _readFromFile(self, message): |
| | 182 | """ Ivan Melnychuk: SOLUTION FOR WINDOWS SYSTEMS: |
| | 183 | Windows does not support returning values from script. |
| | 184 | Therefore temporary files may be used to keep some information like commit message |
| | 185 | 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 |
| | 186 | Even though actual message also may start with such prefix, it is very unlikely that the file exists with such a name by accident |
| | 187 | """ |
| | 188 | if message[:5] == 'file:' and os.path.exists( message[5:] ): |
| | 189 | f = open( message[5:], 'r' ) |
| | 190 | message = f.read() |
| | 191 | f.close() |
| | 192 | return message |
| | 193 | return message; |
| | 194 | |