git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Checking for a valid email address
@ 2009-02-27  3:28 Adam Mercer
  2009-02-27  9:08 ` Miklos Vajna
  2009-02-27  9:20 ` demerphq
  0 siblings, 2 replies; 6+ messages in thread
From: Adam Mercer @ 2009-02-27  3:28 UTC (permalink / raw)
  To: GIT

Hi

We are in the process of migrating some of our repositories from CVS
to Git in a two step process, first to a centralised Git setup then
(hopefully) onto a more distributed development model. In the testing
we have been doing so far the only problem we have run into is
developers not setting their email addresses correctly so the
changelogs are filled with spurious address. Does anyone know of a
pre-commit hook that could check for a valid email address prior to
allowing a commit? Or another way that this can be acheived?

Cheers

Adam

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

* Re: Checking for a valid email address
  2009-02-27  3:28 Checking for a valid email address Adam Mercer
@ 2009-02-27  9:08 ` Miklos Vajna
  2009-02-27 16:19   ` Adam Mercer
  2009-02-27  9:20 ` demerphq
  1 sibling, 1 reply; 6+ messages in thread
From: Miklos Vajna @ 2009-02-27  9:08 UTC (permalink / raw)
  To: Adam Mercer; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 895 bytes --]

On Thu, Feb 26, 2009 at 09:28:59PM -0600, Adam Mercer <ramercer@gmail.com> wrote:
> We are in the process of migrating some of our repositories from CVS
> to Git in a two step process, first to a centralised Git setup then
> (hopefully) onto a more distributed development model. In the testing
> we have been doing so far the only problem we have run into is
> developers not setting their email addresses correctly so the
> changelogs are filled with spurious address. Does anyone know of a
> pre-commit hook that could check for a valid email address prior to
> allowing a commit? Or another way that this can be acheived?

You can use a script like this:

http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/ckaddr.gz

Other helpful git commands to get the current email address:

git var GIT_AUTHOR_IDENT
git config user.name
git config user.email

You can do the rest, hopefully. :)

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: Checking for a valid email address
  2009-02-27  3:28 Checking for a valid email address Adam Mercer
  2009-02-27  9:08 ` Miklos Vajna
@ 2009-02-27  9:20 ` demerphq
  2009-02-27  9:25   ` demerphq
  1 sibling, 1 reply; 6+ messages in thread
From: demerphq @ 2009-02-27  9:20 UTC (permalink / raw)
  To: Adam Mercer; +Cc: GIT

2009/2/27 Adam Mercer <ramercer@gmail.com>:
> Hi
>
> We are in the process of migrating some of our repositories from CVS
> to Git in a two step process, first to a centralised Git setup then
> (hopefully) onto a more distributed development model. In the testing
> we have been doing so far the only problem we have run into is
> developers not setting their email addresses correctly so the
> changelogs are filled with spurious address. Does anyone know of a
> pre-commit hook that could check for a valid email address prior to
> allowing a commit? Or another way that this can be acheived?

If you are using Perl 5.10 or later then you can use the following regex:

my $email = qr {
    (?(DEFINE)
      (?<address>         (?&mailbox) | (?&group))
      (?<mailbox>         (?&name_addr) | (?&addr_spec))
      (?<name_addr>       (?&display_name)? (?&angle_addr))
      (?<angle_addr>      (?&CFWS)? < (?&addr_spec) > (?&CFWS)?)
      (?<group>           (?&display_name) : (?:(?&mailbox_list) | (?&CFWS))? ;
                                             (?&CFWS)?)
      (?<display_name>    (?&phrase))
      (?<mailbox_list>    (?&mailbox) (?: , (?&mailbox))*)

      (?<addr_spec>       (?&local_part) \@ (?&domain))
      (?<local_part>      (?&dot_atom) | (?&quoted_string))
      (?<domain>          (?&dot_atom) | (?&domain_literal))
      (?<domain_literal>  (?&CFWS)? \[ (?: (?&FWS)? (?&dcontent))* (?&FWS)?
                                    \] (?&CFWS)?)
      (?<dcontent>        (?&dtext) | (?&quoted_pair))
      (?<dtext>           (?&NO_WS_CTL) | [\x21-\x5a\x5e-\x7e])

      (?<atext>           (?&ALPHA) | (?&DIGIT) | [!#\$%&'*+-/=?^_`{|}~])
      (?<atom>            (?&CFWS)? (?&atext)+ (?&CFWS)?)
      (?<dot_atom>        (?&CFWS)? (?&dot_atom_text) (?&CFWS)?)
      (?<dot_atom_text>   (?&atext)+ (?: \. (?&atext)+)*)

      (?<text>            [\x01-\x09\x0b\x0c\x0e-\x7f])
      (?<quoted_pair>     \\ (?&text))

      (?<qtext>           (?&NO_WS_CTL) | [\x21\x23-\x5b\x5d-\x7e])
      (?<qcontent>        (?&qtext) | (?&quoted_pair))
      (?<quoted_string>   (?&CFWS)? (?&DQUOTE) (?:(?&FWS)? (?&qcontent))*
                           (?&FWS)? (?&DQUOTE) (?&CFWS)?)

      (?<word>            (?&atom) | (?&quoted_string))
      (?<phrase>          (?&word)+)

      # Folding white space
      (?<FWS>             (?: (?&WSP)* (?&CRLF))? (?&WSP)+)
      (?<ctext>           (?&NO_WS_CTL) | [\x21-\x27\x2a-\x5b\x5d-\x7e])
      (?<ccontent>        (?&ctext) | (?&quoted_pair) | (?&comment))
      (?<comment>         \( (?: (?&FWS)? (?&ccontent))* (?&FWS)? \) )
      (?<CFWS>            (?: (?&FWS)? (?&comment))*
                          (?: (?:(?&FWS)? (?&comment)) | (?&FWS)))

      # No whitespace control
      (?<NO_WS_CTL>       [\x01-\x08\x0b\x0c\x0e-\x1f\x7f])

      (?<ALPHA>           [A-Za-z])
      (?<DIGIT>           [0-9])
      (?<CRLF>            \x0d \x0a)
      (?<DQUOTE>          ")
      (?<WSP>             [\x20\x09])
    )

    (?&address)
}x;

which is a fully RFC compliant perl regex for validating any email address.

Have fun, and if you use it credit Abigail of the Perl community for
writing it.

cheers,
Yves

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

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

* Re: Checking for a valid email address
  2009-02-27  9:20 ` demerphq
@ 2009-02-27  9:25   ` demerphq
  2009-02-27 16:20     ` Adam Mercer
  0 siblings, 1 reply; 6+ messages in thread
From: demerphq @ 2009-02-27  9:25 UTC (permalink / raw)
  To: Adam Mercer; +Cc: GIT

2009/2/27 demerphq <demerphq@gmail.com>:
> 2009/2/27 Adam Mercer <ramercer@gmail.com>:
>> Hi
>>
>> We are in the process of migrating some of our repositories from CVS
>> to Git in a two step process, first to a centralised Git setup then
>> (hopefully) onto a more distributed development model. In the testing
>> we have been doing so far the only problem we have run into is
>> developers not setting their email addresses correctly so the
>> changelogs are filled with spurious address. Does anyone know of a
>> pre-commit hook that could check for a valid email address prior to
>> allowing a commit? Or another way that this can be acheived?
>
> If you are using Perl 5.10 or later then you can use the following regex:
>
> my $email = qr {
>    (?(DEFINE)
>      (?<address>         (?&mailbox) | (?&group))
>      (?<mailbox>         (?&name_addr) | (?&addr_spec))
>      (?<name_addr>       (?&display_name)? (?&angle_addr))
>      (?<angle_addr>      (?&CFWS)? < (?&addr_spec) > (?&CFWS)?)
>      (?<group>           (?&display_name) : (?:(?&mailbox_list) | (?&CFWS))? ;
>                                             (?&CFWS)?)
>      (?<display_name>    (?&phrase))
>      (?<mailbox_list>    (?&mailbox) (?: , (?&mailbox))*)
>
>      (?<addr_spec>       (?&local_part) \@ (?&domain))
>      (?<local_part>      (?&dot_atom) | (?&quoted_string))
>      (?<domain>          (?&dot_atom) | (?&domain_literal))
>      (?<domain_literal>  (?&CFWS)? \[ (?: (?&FWS)? (?&dcontent))* (?&FWS)?
>                                    \] (?&CFWS)?)
>      (?<dcontent>        (?&dtext) | (?&quoted_pair))
>      (?<dtext>           (?&NO_WS_CTL) | [\x21-\x5a\x5e-\x7e])
>
>      (?<atext>           (?&ALPHA) | (?&DIGIT) | [!#\$%&'*+-/=?^_`{|}~])
>      (?<atom>            (?&CFWS)? (?&atext)+ (?&CFWS)?)
>      (?<dot_atom>        (?&CFWS)? (?&dot_atom_text) (?&CFWS)?)
>      (?<dot_atom_text>   (?&atext)+ (?: \. (?&atext)+)*)
>
>      (?<text>            [\x01-\x09\x0b\x0c\x0e-\x7f])
>      (?<quoted_pair>     \\ (?&text))
>
>      (?<qtext>           (?&NO_WS_CTL) | [\x21\x23-\x5b\x5d-\x7e])
>      (?<qcontent>        (?&qtext) | (?&quoted_pair))
>      (?<quoted_string>   (?&CFWS)? (?&DQUOTE) (?:(?&FWS)? (?&qcontent))*
>                           (?&FWS)? (?&DQUOTE) (?&CFWS)?)
>
>      (?<word>            (?&atom) | (?&quoted_string))
>      (?<phrase>          (?&word)+)
>
>      # Folding white space
>      (?<FWS>             (?: (?&WSP)* (?&CRLF))? (?&WSP)+)
>      (?<ctext>           (?&NO_WS_CTL) | [\x21-\x27\x2a-\x5b\x5d-\x7e])
>      (?<ccontent>        (?&ctext) | (?&quoted_pair) | (?&comment))
>      (?<comment>         \( (?: (?&FWS)? (?&ccontent))* (?&FWS)? \) )
>      (?<CFWS>            (?: (?&FWS)? (?&comment))*
>                          (?: (?:(?&FWS)? (?&comment)) | (?&FWS)))
>
>      # No whitespace control
>      (?<NO_WS_CTL>       [\x01-\x08\x0b\x0c\x0e-\x1f\x7f])
>
>      (?<ALPHA>           [A-Za-z])
>      (?<DIGIT>           [0-9])
>      (?<CRLF>            \x0d \x0a)
>      (?<DQUOTE>          ")
>      (?<WSP>             [\x20\x09])
>    )
>
>    (?&address)
> }x;
>
> which is a fully RFC compliant perl regex for validating any email address.

Er, i meant validating whether any email address is well formed of course.

Cheers,
yves



-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

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

* Re: Checking for a valid email address
  2009-02-27  9:08 ` Miklos Vajna
@ 2009-02-27 16:19   ` Adam Mercer
  0 siblings, 0 replies; 6+ messages in thread
From: Adam Mercer @ 2009-02-27 16:19 UTC (permalink / raw)
  To: Miklos Vajna; +Cc: git

On Fri, Feb 27, 2009 at 03:08, Miklos Vajna <vmiklos@frugalware.org> wrote:

> You can use a script like this:
>
> http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/ckaddr.gz
>
> Other helpful git commands to get the current email address:
>
> git var GIT_AUTHOR_IDENT
> git config user.name
> git config user.email
>
> You can do the rest, hopefully. :)

Thanks, thats helpful.

Cheers

Adam

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

* Re: Checking for a valid email address
  2009-02-27  9:25   ` demerphq
@ 2009-02-27 16:20     ` Adam Mercer
  0 siblings, 0 replies; 6+ messages in thread
From: Adam Mercer @ 2009-02-27 16:20 UTC (permalink / raw)
  To: demerphq; +Cc: GIT

On Fri, Feb 27, 2009 at 03:25, demerphq <demerphq@gmail.com> wrote:

>> If you are using Perl 5.10 or later then you can use the following regex:

<snip>

>> which is a fully RFC compliant perl regex for validating any email address.
>
> Er, i meant validating whether any email address is well formed of course.

Thanks, that should be enough...

Cheers

Adam

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

end of thread, other threads:[~2009-02-27 16:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-27  3:28 Checking for a valid email address Adam Mercer
2009-02-27  9:08 ` Miklos Vajna
2009-02-27 16:19   ` Adam Mercer
2009-02-27  9:20 ` demerphq
2009-02-27  9:25   ` demerphq
2009-02-27 16:20     ` Adam Mercer

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 NNTP newsgroup(s).