unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [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
* [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

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  8:10 [Outreachy] Strategy to implement guix git log --pretty=<string> Leo Prikler
2021-01-18 14:45 ` zimoun
  -- strict thread matches above, loose matches on Subject: below --
2021-01-06  4:35 Magali
2021-01-06  8:03 ` Gábor Boskovits
2021-01-14 21:29 ` Ludovic Courtès
2021-01-18 15:02   ` zimoun

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

	https://git.savannah.gnu.org/cgit/guix.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).