On Mon, Sep 13, 2010 at 8:26 AM, Frank Becker <[email protected]> wrote:
> John Admanski [2010-09-13, 16:44 +0200]:
>
> Hi,
>
> > Looks nice, especially with all the cleanup. I can't comment much on the
> Yep, Lucas did a good job there. Also, for me it was a good example on how
> the Autotest code should look like.
>
> > I do note that this code uses lstrip with '* ', which I do worry about a
> Git marks the branch you are on with '^* '. To find the branch the
> repository is on thats what is looked for.
> Do you have a better approach?
>
>
> > + cmd = 'branch --no-color'
> > > + if all:
> > > + cmd = " ".join([cmd, "-a"])
> > > + if remote_tracking:
> > > + cmd = " ".join([cmd, "-r"])
> > > +
> > > + gitlog = self.gitcmd(cmd, True)
> > > + if gitlog.exit_status != 0:
> > > + print gitlog.stderr
> > > + raise error.CmdError('Failed to get git branch', gitlog)
> > > + elif all or remote_tracking:
> > > + return gitlog.stdout.strip('\n')
> > > + else:
> > > + branch = [b.lstrip('* ') for b in
> gitlog.stdout.split('\n') \
> > > + if b.startswith('*')][0]
> > > + return branch
> That's the line we talk about. I'd like to strip off the two 1st characters
> '* '. b[2:] would be equivalent.
>
>
Yeah, if the idea is to find the branch by looking for a line that starts
with '* ' then it's probably better to write it as:
branch = [b[2:] for b in gitlog.stdout.split('\n') if b.startswith('* ')][0]
Bye,
>
> Frank
>
> --
> Frank Becker <[email protected]> (jabber|mail) | http://twitter.com/41i3n8
> GnuPG: 0xADC29ECD | F01B 5E9C 1D09 981B 5B40 50D3 C80F 7459 ADC2 9ECD
> SILC-Net: a8 | Home: http://www.alien8.de | <<</>> http://www.c3d2.de
> "> Freedom is just chaos, with better lighting. <" Alan Dean Foster
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iEYEARECAAYFAkyOQqQACgkQyA90Wa3Cns3+HACfUisZ1v4vAA/oRFefePfHEcP+
> EJYAn2lKThVU8Hx/Sm/nNg2xebCoHl6B
> =9agC
> -----END PGP SIGNATURE-----
>
>
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest