unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / Atom feed
* [Outreachy] Strategy to implement guix git log --pretty=<string>
@ 2021-01-06  4:35 Magali
  2021-01-06  8:03 ` Gábor Boskovits
  2021-01-14 21:29 ` Ludovic Courtès
  0 siblings, 2 replies; 6+ messages in thread
From: Magali @ 2021-01-06  4:35 UTC (permalink / raw)
  To: Gábor Boskovits, zimoun, Guix Devel

Hello Guix,

As you might know, as part of my Outreachy internship I'm currently
working on implementing the subcommand 'guix git log', for browsing the
history of all packages. So far, it works with '--oneline' and
'--format=<FORMAT>', and FORMAT can be 'oneline', 'medium' or 'full'. If
you want to see it, the code can be found at
https://gitlab.com/magalilemes/guix

On the road to adding another option to the subcommand,
'--pretty=<string>' arose as an idea. With git log, you can do something
like
git log pretty=<string>
And this string can have placeholders, such as %h for showing the short
hash of a commit, and %s for showing the commit subject. For instance,
you could have git log --pretty="%h %s" and this would display the
commit history log with the short hash and subject of commits.

So, in order to implement 'guix git log --pretty=<string>', I'd like
help with a strategy to parse the string. Any examples, ideas and tips
would be really appreciated.

Cheers,

Magali




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

* Re: [Outreachy] Strategy to implement guix git log --pretty=<string>
  2021-01-06  4:35 [Outreachy] Strategy to implement guix git log --pretty=<string> Magali
@ 2021-01-06  8:03 ` Gábor Boskovits
  2021-01-14 21:29 ` Ludovic Courtès
  1 sibling, 0 replies; 6+ messages in thread
From: Gábor Boskovits @ 2021-01-06  8:03 UTC (permalink / raw)
  To: Magali; +Cc: Guix Devel

Hello,

Magali <magalilemes00@gmail.com> ezt írta (időpont: 2021. jan. 6., Sze, 5:35):
>
> Hello Guix,
>
> As you might know, as part of my Outreachy internship I'm currently
> working on implementing the subcommand 'guix git log', for browsing the
> history of all packages. So far, it works with '--oneline' and
> '--format=<FORMAT>', and FORMAT can be 'oneline', 'medium' or 'full'. If
> you want to see it, the code can be found at
> https://gitlab.com/magalilemes/guix
>
> On the road to adding another option to the subcommand,
> '--pretty=<string>' arose as an idea. With git log, you can do something
> like
> git log pretty=<string>
> And this string can have placeholders, such as %h for showing the short
> hash of a commit, and %s for showing the commit subject. For instance,
> you could have git log --pretty="%h %s" and this would display the
> commit history log with the short hash and subject of commits.
>
> So, in order to implement 'guix git log --pretty=<string>', I'd like
> help with a strategy to parse the string. Any examples, ideas and tips
> would be really appreciated.
>

From the top of my head two things come to mind, you could either
tokenize the string and handle it as a list,
or you could do a regex matching. I don't think anything more
complicated is needed to handle this.

You can find the relevant docs here:
https://www.gnu.org/software/guile/manual/html_node/Strings.html
https://www.gnu.org/software/guile/manual/html_node/Regular-Expressions.html




> Cheers,
>
> Magali
>
>

Regards,
g_bor
-- 
OpenPGP Key Fingerprint: 7988:3B9F:7D6A:4DBF:3719:0367:2506:A96C:CF63:0B21


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

* Re: [Outreachy] Strategy to implement guix git log --pretty=<string>
  2021-01-06  4:35 [Outreachy] Strategy to implement guix git log --pretty=<string> Magali
  2021-01-06  8:03 ` Gábor Boskovits
@ 2021-01-14 21:29 ` Ludovic Courtès
  2021-01-18 15:02   ` zimoun
  1 sibling, 1 reply; 6+ messages in thread
From: Ludovic Courtès @ 2021-01-14 21:29 UTC (permalink / raw)
  To: Magali; +Cc: Guix Devel

Hi Magali,

Magali <magalilemes00@gmail.com> skribis:

> As you might know, as part of my Outreachy internship I'm currently
> working on implementing the subcommand 'guix git log', for browsing the
> history of all packages. So far, it works with '--oneline' and
> '--format=<FORMAT>', and FORMAT can be 'oneline', 'medium' or 'full'. If
> you want to see it, the code can be found at
> https://gitlab.com/magalilemes/guix

Nice to see progress there!  Don’t hesitate to stop by on IRC or the
mailing list when you have questions or when in doubt, or just to share
your latest achievements.

> On the road to adding another option to the subcommand,
> '--pretty=<string>' arose as an idea. With git log, you can do something
> like
> git log pretty=<string>
> And this string can have placeholders, such as %h for showing the short
> hash of a commit, and %s for showing the commit subject. For instance,
> you could have git log --pretty="%h %s" and this would display the
> commit history log with the short hash and subject of commits.

I was going to suggest postponing this feature, but I see in the repo
you already came up with a reasonable solution (maybe not fool-proof,
because it should be possible to escape the percent character, and then
you can’t just use regexps, but it’s probably good enough.)

Thanks for the update,
Ludo’.


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

* Re: [Outreachy] Strategy to implement guix git log --pretty=<string>
  2021-01-14 21:29 ` Ludovic Courtès
@ 2021-01-18 15:02   ` zimoun
  0 siblings, 0 replies; 6+ messages in thread
From: zimoun @ 2021-01-18 15:02 UTC (permalink / raw)
  To: Ludovic Courtès, Magali; +Cc: Guix Devel

Hi Ludo,

On Thu, 14 Jan 2021 at 22:29, Ludovic Courtès <ludo@gnu.org> wrote:

> I was going to suggest postponing this feature, but I see in the repo
> you already came up with a reasonable solution (maybe not fool-proof,
> because it should be possible to escape the percent character, and then
> you can’t just use regexps, but it’s probably good enough.)

Yeah, my initial idea was to use PEG.  But the documentation is not easy
to grasp so using regular expressions seems enough to underline the
functionality, with the option to improve later.

Well, the reasonable goal for the project is to run something as:

  ./pre-inst-env guix git log --grep=<term> --pretty=“%h %s”


What is not clear for now:

 - walk the history tree; currently done with something similar to
   ’commit-closure’ and I do not know if all the branches at merge
   points are correctly walked;
 - lazy walk, for example: “git log --oneline | head -n10” does not need to
   traverse all the history tree but only the first 10 commits.
   Something like “co-routine“ (not sure if it is the correct word).  It
   is not a big deal for now because it is fast enough; but far to be
   optimal. ;-)

And these start being an issue with a couple channels.

Cheers,
simon




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

* Re: [Outreachy] Strategy to implement guix git log --pretty=<string>
  2021-01-06  8:10 Leo Prikler
@ 2021-01-18 14:45 ` zimoun
  0 siblings, 0 replies; 6+ messages in thread
From: zimoun @ 2021-01-18 14:45 UTC (permalink / raw)
  To: Leo Prikler, magalilemes00; +Cc: guix-devel

Hi Leo,

On Wed, 06 Jan 2021 at 09:10, Leo Prikler <leo.prikler@student.tugraz.at> wrote:

> have you looked into (ice-9 peg)?  An easy pretty grammar, that would
> catch your example would be the following:

This should be my preference too. :-) However, it seems easier and
faster to use simple regular expressions.  At least, at first PoC.

Thanks for the suggestion.

Cheers,
simon


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

* [Outreachy] Strategy to implement guix git log --pretty=<string>
@ 2021-01-06  8:10 Leo Prikler
  2021-01-18 14:45 ` zimoun
  0 siblings, 1 reply; 6+ messages in thread
From: Leo Prikler @ 2021-01-06  8:10 UTC (permalink / raw)
  To: magalilemes00; +Cc: guix-devel

Hello Magali,

have you looked into (ice-9 peg)?  An easy pretty grammar, that would
catch your example would be the following:

--8<---------------cut here---------------start------------->8---
(use-modules (ice-9 peg))

(define-peg-pattern commit-hash all (ignore "%h"))
(define-peg-pattern subject all (ignore "%s"))

(define-peg-pattern pretty body
  (* (or commit-hash
         subject
         (* (and (not-followed-by "%") peg-any)))))

(peg:tree (match-pattern pretty "%h %s")) ;; => (commit-hash " "
subject)
--8<---------------cut here---------------end--------------->8---

Of course you have to extend it with all the other percent escapes.
Then you simply map a match-lambda over the "tree", which if given a
symbol returns a string containng the actual value and if given a
string returns the string unchanged.  Finally you string-concatenate
them.  Naturally, you have to check whether the string was valid as
well -- a lone "%" should not match, for instance.

Cheers,
Leo



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

end of thread, other threads:[~2021-01-18 15:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-06  4:35 [Outreachy] Strategy to implement guix git log --pretty=<string> Magali
2021-01-06  8:03 ` Gábor Boskovits
2021-01-14 21:29 ` Ludovic Courtès
2021-01-18 15:02   ` zimoun
2021-01-06  8:10 Leo Prikler
2021-01-18 14:45 ` zimoun

unofficial mirror of guix-devel@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/guix-devel/0 guix-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guix-devel guix-devel/ https://yhetil.org/guix-devel \
		guix-devel@gnu.org
	public-inbox-index guix-devel

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.gnu.guix.devel
	nntp://news.gmane.io/gmane.comp.gnu.guix.devel


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git