git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 1/2] Set HOME to the test directory to avoid reading ~/.stgitrc
@ 2006-11-29  3:59 Pavel Roskin
  2006-11-29  3:59 ` [PATCH 2/2] Don't require config file for "stg mail" Pavel Roskin
  0 siblings, 1 reply; 5+ messages in thread
From: Pavel Roskin @ 2006-11-29  3:59 UTC (permalink / raw
  To: git, Catalin Marinas

This makes the tests more system independent and allows better testing
for "stg mail" command.

Signed-off-by: Pavel Roskin <proski@gnu.org>
---

 t/test-lib.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index 6339c54..459d5cb 100755
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -193,7 +193,8 @@ test_done () {
 # Test the binaries we have just built.  The tests are kept in
 # t/ subdirectory and are run in trash subdirectory.
 PATH=$(pwd)/..:$PATH
-export PATH
+HOME=$(pwd)/trash
+export PATH HOME
 
 
 # Test repository

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] Don't require config file for "stg mail"
  2006-11-29  3:59 [PATCH 1/2] Set HOME to the test directory to avoid reading ~/.stgitrc Pavel Roskin
@ 2006-11-29  3:59 ` Pavel Roskin
  2006-11-29 16:29   ` Catalin Marinas
  0 siblings, 1 reply; 5+ messages in thread
From: Pavel Roskin @ 2006-11-29  3:59 UTC (permalink / raw
  To: git, Catalin Marinas

When calculating the string to be used in the From: field, don't require
it to come from the configuration file.  Instead, reuse already known
authname and authemail values as the default.  They can be taken from
the GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL environment variables.

Signed-off-by: Pavel Roskin <proski@gnu.org>
---

 stgit/commands/mail.py |   15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/stgit/commands/mail.py b/stgit/commands/mail.py
index 176d7a2..70b091f 100644
--- a/stgit/commands/mail.py
+++ b/stgit/commands/mail.py
@@ -122,18 +122,13 @@ options = [make_option('-a', '--all',
                        action = 'store_true')]
 
 
-def __get_sender():
-    """Return the 'authname <authemail>' string as read from the
-    configuration file
+def __get_sender(authname, authemail):
+    """Return the string to be used in the From: field
     """
     if config.has_option('stgit', 'sender'):
         return config.get('stgit', 'sender')
-    elif config.has_option('stgit', 'authname') \
-             and config.has_option('stgit', 'authemail'):
-        return '%s <%s>' % (config.get('stgit', 'authname'),
-                            config.get('stgit', 'authemail'))
     else:
-        raise CmdException, 'unknown sender details'
+        return '%s <%s>' % (authname, authemail)
 
 def __parse_addresses(addresses):
     """Return a two elements tuple: (from, [to])
@@ -298,7 +293,7 @@ def __edit_message(msg):
 def __build_cover(tmpl, total_nr, msg_id, options):
     """Build the cover message (series description) to be sent via SMTP
     """
-    sender = __get_sender()
+    sender = __get_sender(authname, authemail)
 
     if options.version:
         version_str = ' %s' % options.version
@@ -372,7 +367,7 @@ def __build_message(tmpl, patch, patch_nr, total_nr, msg_id, ref_id, options):
     commname = p.get_commname();
     commemail = p.get_commemail();
 
-    sender = __get_sender()
+    sender = __get_sender(authname, authemail)
 
     fromauth = '%s <%s>' % (authname, authemail)
     if fromauth != sender:

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] Don't require config file for "stg mail"
  2006-11-29  3:59 ` [PATCH 2/2] Don't require config file for "stg mail" Pavel Roskin
@ 2006-11-29 16:29   ` Catalin Marinas
  2006-11-29 23:27     ` Pavel Roskin
  0 siblings, 1 reply; 5+ messages in thread
From: Catalin Marinas @ 2006-11-29 16:29 UTC (permalink / raw
  To: Pavel Roskin; +Cc: git

On 29/11/06, Pavel Roskin <proski@gnu.org> wrote:
> When calculating the string to be used in the From: field, don't require
> it to come from the configuration file.  Instead, reuse already known
> authname and authemail values as the default.  They can be taken from
> the GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL environment variables.

Your patch uses the author of the patch which can be different from
the person sending the e-mail. It could indeed use the author from GIT
variables or configuration (not the patch author) and I already have a
patch from Karl Hasselström for this (which I haven't found the time
to check properly).

The reason I added a sender option is because the sender (that gets
added to the e-mail headers) may differ from the author of the patch.
I use one e-mail address as the author but I might be behind an SMTP
server which only allows a different e-mail address and therefore I
set the sender accordingly.

Once I merge Karl's patch, I'll modify StGIT to use the GIT defaults
if there is no sender configured.

-- 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] Don't require config file for "stg mail"
  2006-11-29 16:29   ` Catalin Marinas
@ 2006-11-29 23:27     ` Pavel Roskin
  2006-11-30  8:32       ` Catalin Marinas
  0 siblings, 1 reply; 5+ messages in thread
From: Pavel Roskin @ 2006-11-29 23:27 UTC (permalink / raw
  To: Catalin Marinas; +Cc: git

Hello, Catalin!

On Wed, 2006-11-29 at 16:29 +0000, Catalin Marinas wrote:
> On 29/11/06, Pavel Roskin <proski@gnu.org> wrote:
> > When calculating the string to be used in the From: field, don't require
> > it to come from the configuration file.  Instead, reuse already known
> > authname and authemail values as the default.  They can be taken from
> > the GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL environment variables.
> 
> Your patch uses the author of the patch which can be different from
> the person sending the e-mail. It could indeed use the author from GIT
> variables or configuration (not the patch author) and I already have a
> patch from Karl Hasselström for this (which I haven't found the time
> to check properly).

The funny thing it, GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL are only used
in the code to determine the author of the patch.

Apparently, things are more twisted than I expected, so they need some
untangling first.

> Once I merge Karl's patch, I'll modify StGIT to use the GIT defaults
> if there is no sender configured.

Sounds good.

-- 
Regards,
Pavel Roskin


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] Don't require config file for "stg mail"
  2006-11-29 23:27     ` Pavel Roskin
@ 2006-11-30  8:32       ` Catalin Marinas
  0 siblings, 0 replies; 5+ messages in thread
From: Catalin Marinas @ 2006-11-30  8:32 UTC (permalink / raw
  To: Pavel Roskin; +Cc: git

On 29/11/06, Pavel Roskin <proski@gnu.org> wrote:
> On Wed, 2006-11-29 at 16:29 +0000, Catalin Marinas wrote:
> > Your patch uses the author of the patch which can be different from
> > the person sending the e-mail. It could indeed use the author from GIT
> > variables or configuration (not the patch author) and I already have a
> > patch from Karl Hasselström for this (which I haven't found the time
> > to check properly).
>
> The funny thing it, GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL are only used
> in the code to determine the author of the patch.

Yes, but only for a newly created patch. If you import a patch from an
mbox or e-mail or simply pass the --author option to "new", the author
will be different.

-- 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-11-30  8:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-29  3:59 [PATCH 1/2] Set HOME to the test directory to avoid reading ~/.stgitrc Pavel Roskin
2006-11-29  3:59 ` [PATCH 2/2] Don't require config file for "stg mail" Pavel Roskin
2006-11-29 16:29   ` Catalin Marinas
2006-11-29 23:27     ` Pavel Roskin
2006-11-30  8:32       ` Catalin Marinas

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).