Last month (February 21st) I posed the question, how a
"verifymsg" script could change the message it should verify.
At the end of this text there is a "cvs-verifymsg"-Patch
that solves this problem.
My original problem was, the following:
The developers may specify a bug-id with
the log message they enter with a "cvs commit". These
information should NOT appear within the log message
later on; they are used later on externally.
If a log message was given using the "-m" option of "cvs
commit", it normally is not possible to modify the
message the user gave using a script specified in
the repository:
editinfo - can change log message, but is not
invoked if commit took place remotely.
verifymsg - is invoked for each commit, but
cannot change the message
This patch causes the changes of a "verifymsg" script to
the log message (a temporary file) to affect the log
message.
This patch is based on CVS 1.10.8.
These changes work for us, but use them at your own
risk!
Heiner
--
___ _ _____ Heiner Steven [EMAIL PROTECTED] /The expressed
opinions
| _ |_)_ |_ _|__ __ BinTec Communications AG __/are mine, not
BinTec's --
| _ \ | ' \| |/ -_) _| Suedwestpark 94 / ...even if they should
be ;-)
|___/_|_||_|_|\___\__| D-90449 Nuernberg / http://www.bintec.de/
=======================================================
*** src/src.org/commit.c Tue Feb 22 10:09:33 2000
--- src/commit.c Tue Feb 22 08:55:06 2000
***************
*** 512,518 ****
/* Run the user-defined script to verify/check information in
*the log message
*/
! do_verify (saved_message, (char *)NULL);
/* We always send some sort of message, even if empty. */
/* FIXME: is that true? There seems to be some code in do_editor
--- 512,518 ----
/* Run the user-defined script to verify/check information in
*the log message
*/
! do_verify (&saved_message, (char *)NULL);
/* We always send some sort of message, even if empty. */
/* FIXME: is that true? There seems to be some code in do_editor
***************
*** 1277,1283 ****
if (use_editor)
do_editor (finfo->update_dir, &saved_message,
finfo->repository, ulist);
! do_verify (saved_message, finfo->repository);
}
p = findnode (cilist, finfo->file);
--- 1277,1283 ----
if (use_editor)
do_editor (finfo->update_dir, &saved_message,
finfo->repository, ulist);
! do_verify (&saved_message, finfo->repository);
}
p = findnode (cilist, finfo->file);
***************
*** 1588,1594 ****
got_message = 1;
if (use_editor)
do_editor (update_dir, &saved_message, real_repos, ulist);
! do_verify (saved_message, real_repos);
free (real_repos);
return (R_PROCESS);
}
--- 1588,1594 ----
got_message = 1;
if (use_editor)
do_editor (update_dir, &saved_message, real_repos, ulist);
! do_verify (&saved_message, real_repos);
free (real_repos);
return (R_PROCESS);
}
*** src/src.org/cvs.h Tue Feb 22 10:09:34 2000
--- src/cvs.h Tue Feb 22 08:55:36 2000
***************
*** 577,583 ****
void do_editor PROTO((char *dir, char **messagep,
char *repository, List * changes));
! void do_verify PROTO((char *message, char *repository));
typedef int (*CALLBACKPROC) PROTO((int *pargc, char *argv[], char
*where,
char *mwhere, char *mfile, int shorten, int local_specified,
--- 577,583 ----
void do_editor PROTO((char *dir, char **messagep,
char *repository, List * changes));
! void do_verify PROTO((char **messagep, char *repository));
typedef int (*CALLBACKPROC) PROTO((int *pargc, char *argv[], char
*where,
char *mwhere, char *mfile, int shorten, int local_specified,
*** src/src.org/import.c Tue Feb 22 10:09:37 2000
--- src/import.c Tue Feb 22 08:56:37 2000
***************
*** 220,226 ****
do_editor ((char *) NULL, &message, repository,
(List *) NULL);
}
! do_verify (message, repository);
msglen = message == NULL ? 0 : strlen (message);
if (msglen == 0 || message[msglen - 1] != '\n')
{
--- 220,226 ----
do_editor ((char *) NULL, &message, repository,
(List *) NULL);
}
! do_verify (&message, repository);
msglen = message == NULL ? 0 : strlen (message);
if (msglen == 0 || message[msglen - 1] != '\n')
{
*** src/src.org/logmsg.c Tue Feb 22 10:09:37 2000
--- src/logmsg.c Tue Feb 22 08:58:25 2000
***************
*** 385,397 ****
independant of the running of an editor for getting a message.
*/
void
! do_verify (message, repository)
! char *message;
char *repository;
{
FILE *fp;
char *fname;
int retcode = 0;
#ifdef CLIENT_SUPPORT
if (client_active)
--- 385,403 ----
independant of the running of an editor for getting a message.
*/
void
! do_verify (messagep, repository)
! char **messagep;
char *repository;
{
FILE *fp;
char *fname;
int retcode = 0;
+ char *message = *messagep;
+ struct stat pre_stbuf, post_stbuf;
+ char *line;
+ char *p;
+ int line_length;
+ size_t line_chars_allocated;
#ifdef CLIENT_SUPPORT
if (client_active)
***************
*** 439,444 ****
--- 445,453 ----
if (verifymsg_script)
{
+ if ( CVS_STAT (fname, &pre_stbuf) == -1)
+ pre_stbuf.st_mtime = 0;
+
run_setup (verifymsg_script);
run_arg (fname);
if ((retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY,
***************
*** 452,457 ****
--- 461,508 ----
error (1, retcode == -1 ? errno : 0,
"Message verification failed");
}
+
+ /* The verification script completed successfully.
+ Put the entire message back into the *messagep variable
+ */
+
+ fp = open_file (fname, "r");
+ if ( *messagep )
+ free (*messagep);
+
+ if ( CVS_STAT (fname, &post_stbuf) != 0)
+ error (1, errno, "cannot find size of temp file %s", fname);
+
+ if ( post_stbuf.st_size == 0 )
+ *messagep = NULL;
+ else
+ {
+ *messagep = (char *) xmalloc (post_stbuf.st_size + 1);
+ *messagep [0] = '\0';
+ }
+ message = *messagep;
+
+ line = NULL;
+ line_chars_allocated = 0;
+ if (*messagep) {
+ p = *messagep;
+ while ( 1 )
+ {
+ line_length = getline (&line, &line_chars_allocated, fp);
+ if (line_length == -1)
+ {
+ if (ferror (fp))
+ error (0, errno, "warning: cannot read %s", fname);
+ break;
+ }
+ (void) strcpy (p, line);
+ p += line_length;
+ }
+ }
+ if (fclose (fp) < 0)
+ error (0, errno, "warning: cannot close %s", fname);
+ if (line)
+ free (line);
}
/* Delete the temp file */