[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: patch to display new PR number for new submissions
From: |
Andrew J. Gray |
Subject: |
Re: patch to display new PR number for new submissions |
Date: |
Sun, 2 Feb 2003 19:32:40 +1100 |
> >>Now that 4.0 beta2 is out the door please review
> >>(and hopefully accept) the following patch which
> >>allows send-pr and "pr-edit --submit" to display
> >>newly created PR numbers.
>
> >I try to code modifications to your patch along these lines.
I have coded modifications to your patch along the lines I
suggested. The modified patch is at the end of this message. Please
have a look at it and let me know (a) if it meets the requirements you
were addressing with the original patch, and (b) if there are any
problems with it.
Since this change is an enhancement and modifies the gnatsd command
protocol I am thinking it should not be included in GNATS 4.0 final,
but put on a 4.1 branch. What do people think?
--
Andrew J. Gray
Index: doc/gnats.texi
===================================================================
RCS file: /cvsroot/gnats/gnats/doc/gnats.texi,v
retrieving revision 1.40
diff -u -p -r1.40 gnats.texi
--- doc/gnats.texi 25 Nov 2002 08:48:44 -0000 1.40
+++ doc/gnats.texi 2 Feb 2003 08:31:04 -0000
@@ -1386,8 +1386,9 @@ lock is cleared.
@code{211 (CODE_SEND_PR)}
@*The client should now transmit the new PR text using the normal
quoting mechanism. After the PR has been sent, the server will respond
-with either a @code{200 (CODE_OK)} response indicating that the new PR
-has been created (and mail sent to the appropriate persons), or one or
+with either @code{351 (CODE_INFORMATION_FILLER)} and
address@hidden (CODE_INFORMATION)} responses indicating that the new PR
+has been created and supplying the number assigned to it, or one or
more error codes listing problems with the new PR text.
@item CHDB @var{database}
Index: doc/p-admin.texi
===================================================================
RCS file: /cvsroot/gnats/gnats/doc/p-admin.texi,v
retrieving revision 1.34
diff -u -p -r1.34 p-admin.texi
--- doc/p-admin.texi 27 Nov 2002 22:04:38 -0000 1.34
+++ doc/p-admin.texi 2 Feb 2003 08:31:18 -0000
@@ -2083,7 +2083,7 @@ The usage for @code{pr-edit} is:
@smallexample
pr-edit [ -l @var{username} | address@hidden ] [ -u | --unlockdb ]
[ -L | --lockdb ] [ -U | --unlockdb ] [ -c | --check ]
- [ -C | --check-initial ] [ -s | --submit ]
+ [ -C | --check-initial ] [ -s | --submit [ --show-prnum ] ]
[ -a @var{field} | --append address@hidden ]
[ -r @var{field} | address@hidden ] [ --delete-pr ]
[ -R @var{reason} | address@hidden ]
@@ -2147,9 +2147,13 @@ rather than proposed edits of existing P
@itemx --submit
Used to submit a new PR to the database. The PR is read in and verified
for content; if the PR is valid as an initial PR, it is then added to
-the database. A zero exit code is returned if the submission was
-successful. Otherwise, the reason(s) for the PR being rejected are
-printed to stdout, and a non-zero exit code is returned.
+the database. If the submission a zero exit code is returned. Otherwise, the
+reason(s) for the PR being rejected are
+printed, and a non-zero exit code is returned.
+
address@hidden --show-prnum
+This option is used with the @code{--submit} option to display the PR
+number associated with the submitted PR.
@end table
@noindent The following options require a PR number to be given.
Index: gnats/client.c
===================================================================
RCS file: /cvsroot/gnats/gnats/gnats/client.c,v
retrieving revision 1.46
diff -u -p -r1.46 client.c
--- gnats/client.c 25 Nov 2002 13:58:33 -0000 1.46
+++ gnats/client.c 2 Feb 2003 08:31:23 -0000
@@ -334,7 +334,8 @@ get_reply (FILE *outfp)
break;
case CODE_INFORMATION:
- fprintf (outfp, "%s\n", r->text);
+ if (outfp != NULL)
+ fprintf (outfp, "%s\n", r->text);
break;
case CODE_NONEXISTENT_PR:
@@ -1216,7 +1217,7 @@ netSetEditEmailAddr (const char *addr)
}
static void
-netSendPRCmd (const char *cmd, FILE *file)
+netSendPRCmd (const char *cmd, FILE *file, int show_information)
{
char *line;
if (debug)
@@ -1233,13 +1234,13 @@ netSendPRCmd (const char *cmd, FILE *fil
}
fprintf (serv_write, ".\r\n");
/* if get_reply finds errors it writes messages and doesn't return */
- get_reply (stdout);
+ get_reply (show_information ? stdout : NULL);
}
void
netCheckPR (FILE *file, int initial)
{
- netSendPRCmd (initial ? "CHEK INIT" : "CHEK", file);
+ netSendPRCmd (initial ? "CHEK INIT" : "CHEK", file, 1);
}
void
@@ -1298,9 +1299,9 @@ netEditField (FILE *fp, const char *prnu
}
void
-netSubmitNewPR (FILE *file)
+netSubmitNewPR (FILE *file, int show_prnum)
{
- netSendPRCmd ("SUBM", file);
+ netSendPRCmd ("SUBM", file, show_prnum);
}
void
@@ -1310,7 +1311,7 @@ netModifyPR (FILE *file, const char *prN
netSetEditEmailAddr (editEmailAddr);
asprintf (&buf, "EDIT %s", prNum);
- netSendPRCmd (buf, file);
+ netSendPRCmd (buf, file, 1);
free (buf);
}
Index: gnats/cmds.c
===================================================================
RCS file: /cvsroot/gnats/gnats/gnats/cmds.c,v
retrieving revision 1.70
diff -u -p -r1.70 cmds.c
--- gnats/cmds.c 14 Oct 2002 11:42:25 -0000 1.70
+++ gnats/cmds.c 2 Feb 2003 08:31:29 -0000
@@ -478,6 +478,7 @@ GNATS_subm (int ac, char **av ATTRIBUTE_
char *tempfile;
FILE *fp;
ErrorDesc err;
+ int new_pr_num;
if (ac != 0)
{
@@ -507,9 +508,11 @@ GNATS_subm (int ac, char **av ATTRIBUTE_
{
if (daemon_lock_gnats (FALSE) == 0)
{
- if (submit_pr (currentDatabase, fp, &err) != 0)
+ if ((new_pr_num = submit_pr (currentDatabase, fp, &err)) != 0)
{
- printf ("%d PR added.\r\n", CODE_OK);
+ printf ("%d-The added PR number is:\r\n",
+ CODE_INFORMATION_FILLER);
+ printf ("%d %d\r\n", CODE_INFORMATION, new_pr_num);
fflush (stdout);
}
else
Index: gnats/file-pr.c
===================================================================
RCS file: /cvsroot/gnats/gnats/gnats/file-pr.c,v
retrieving revision 1.51
diff -u -p -r1.51 file-pr.c
--- gnats/file-pr.c 1 Nov 2002 11:37:51 -0000 1.51
+++ gnats/file-pr.c 2 Feb 2003 08:31:32 -0000
@@ -930,11 +930,13 @@ getBugNumber (const DatabaseInfo databas
return bug_number;
}
-/* Submit the PR whose contents are referred to by FP. */
+/* Submit the PR whose contents are referred to by FP.
+ * Return the new PR number if it's a new PR, or return the PR number of
+ * the PR which was appended to if it's an existing PR. */
int
submit_pr (const DatabaseInfo database, FILE *fp, ErrorDesc *err)
{
- int result;
+ int result, retval;
PR *pr = allocPR (database);
result = (read_header (pr, fp) >= 0);
@@ -956,10 +958,8 @@ submit_pr (const DatabaseInfo database,
}
else
{
- if (append_report (fp, pr, prID, err) != 0)
- {
- result = 0;
- }
+ retval = append_report (fp, pr, prID, err);
+ result = (retval == 0) ? atoi (prID) : 0;
free_pr (pr);
}
free (prID);
@@ -967,10 +967,8 @@ submit_pr (const DatabaseInfo database,
else
{
read_pr (pr, fp, 0);
- if (createNewPRFile (pr, createCategoryDirs (database), err) < 0)
- {
- result = 0;
- }
+ retval = createNewPRFile (pr, createCategoryDirs (database), err);
+ result = (retval < 0) ? 0 : retval;
}
}
else
Index: gnats/gnats.h
===================================================================
RCS file: /cvsroot/gnats/gnats/gnats/gnats.h,v
retrieving revision 1.52
diff -u -p -r1.52 gnats.h
--- gnats/gnats.h 31 Oct 2002 23:43:28 -0000 1.52
+++ gnats/gnats.h 2 Feb 2003 08:31:33 -0000
@@ -292,7 +292,7 @@ extern void netEditField (FILE *fieldDat
const char *editUserEmailAddr, int appendToField,
char *reason);
-extern void netSubmitNewPR (FILE *file);
+extern void netSubmitNewPR (FILE *file, int show_prnum);
extern void netModifyPR (FILE *file, const char *prNum,
const char *editUserEmailAddr);
extern void netLockDB (void);
Index: gnats/pr-edit.c
===================================================================
RCS file: /cvsroot/gnats/gnats/gnats/pr-edit.c,v
retrieving revision 1.37
diff -u -p -r1.37 pr-edit.c
--- gnats/pr-edit.c 1 Nov 2002 09:02:23 -0000 1.37
+++ gnats/pr-edit.c 2 Feb 2003 08:31:36 -0000
@@ -43,6 +43,7 @@ enum {
} edit_options;
#define DELETE_PR_OPT 256
+#define SHOW_PRNUM_OPT 257
struct option long_options[] =
{
@@ -61,6 +62,7 @@ struct option long_options[] =
{"filename", 1, NULL, 'f'},
{"version", 0, NULL, 'V'},
{"delete-pr", 0, NULL, DELETE_PR_OPT},
+ {"show-prnum", 0, NULL, SHOW_PRNUM_OPT},
{"help", 0, NULL, 'h'},
{"user", 1, NULL, 'v'},
{"passwd", 1, NULL, 'w'},
@@ -83,9 +85,10 @@ Modify database.\n\
-L --lockdb lock the whole database\n\
-U --unlockdb unlock the database\n\
-c --check check input for editting, don't change PR\n\
- -C --check-initial check input for submition, don't submit new PR\n\
+ -C --check-initial check input for submission, don't submit new PR\n\
-s --submit submit new PR\n",
"\
+ --show-prnum display the newly created PR number (for
--submit)\n\
-a --append=FIELDNAME append input to FIELDNAME\n\
-r --replace=FIELDNAME replace FIELDNAME with input\n\
--delete-pr delete PR from the database completely\n\
@@ -145,7 +148,7 @@ read_file (FILE *inp)
static void
handleNetworkEdit (int edit_options, FILE *fpin, char *prnum, char *username,
char *editEmailAddr, char *processid, char *fieldname,
- char *reason)
+ char *reason, int show_prnum)
{
int exitcode = 0;
@@ -165,7 +168,7 @@ handleNetworkEdit (int edit_options, FIL
break;
case SUBMIT:
{
- netSubmitNewPR (fpin);
+ netSubmitNewPR (fpin, show_prnum);
break;
}
case CHECK:
@@ -216,6 +219,7 @@ main (int argc, char **argv)
int networkmode = 0;
char *editUserEmailAddr = NULL;
char *reason = NULL;
+ int show_prnum = 0;
program_name = basename (argv[0]);
edit_options = MODIFY;
@@ -233,6 +237,10 @@ main (int argc, char **argv)
debug = 1;
break;
+ case SHOW_PRNUM_OPT:
+ show_prnum = 1;
+ break;
+
case 'f':
fp = fopen (optarg, "r");
/* If they gave a bogus argument, then exit right away; we don't
@@ -398,7 +406,7 @@ main (int argc, char **argv)
exit (3);
}
handleNetworkEdit (edit_options, fp, prnum, username, editUserEmailAddr,
- processid, fieldname, reason);
+ processid, fieldname, reason, show_prnum);
}
database = init_gnats (program_name, nameOfDatabase, &err);
@@ -467,6 +475,10 @@ main (int argc, char **argv)
case SUBMIT:
{
result = submit_pr (database, fp, &err);
+ if (show_prnum && result)
+ {
+ fprintf (stdout, "%d\n", result);
+ }
break;
}
case APPEND:
Index: send-pr/send-pr.sh
===================================================================
RCS file: /cvsroot/gnats/gnats/send-pr/send-pr.sh,v
retrieving revision 1.23
diff -u -p -r1.23 send-pr.sh
--- send-pr/send-pr.sh 29 Oct 2002 09:58:15 -0000 1.23
+++ send-pr/send-pr.sh 2 Feb 2003 08:31:40 -0000
@@ -536,8 +536,8 @@ do
echo "$COMMAND: problem report mailed"
xs=0; exit
else
- if $LIBEXECDIR/pr-edit --submit < $REF; then
- echo "$COMMAND: problem report filed"
+ if pr_num=`$LIBEXECDIR/pr-edit --submit --show-prnum < $REF` ; then
+ echo "$COMMAND: problem report $pr_num filed"
xs=0; exit
else
echo "$COMMAND: the problem report is not sent."
- Re: patch to display new PR number for new submissions,
Andrew J. Gray <=