guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [outreachy] Walk through the Git history (guix git {authenticate,log


From: zimoun
Subject: Re: [outreachy] Walk through the Git history (guix git {authenticate,log})
Date: Sat, 12 Dec 2020 13:24:02 +0100

Hi Magali,

On Fri, 11 Dec 2020 at 16:01, Magali <magalilemes00@gmail.com> wrote:

> I think #2 is the way to go. It may be more difficult to implement right
> now, but in the future it'll make things easier if we think about adding
> an option that allows us to choose the order the commits will be shown,
> for instance.

Awaiting how to walk the history tree, I am proposing to use the loop as
Mathieu said.  However, ’match’ is preferred over ’car’.  Something
along:

--8<---------------cut here---------------start------------->8---
$ guix repl
GNU Guile 3.0.4
Copyright (C) 1995-2020 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guix-user)> ,use(guix git)
scheme@(guix-user)> ,use(git)
scheme@(guix-user)> ,use(guix channels)
scheme@(guix-user)> ,use(ice-9 match)
scheme@(guix-user)> ,use(srfi srfi-1)    
scheme@(guix-user)> (define cache (url-cache-directory (channel-url 
%default-guix-channel)))
scheme@(guix-user)> (define repo (repository-open cache))
scheme@(guix-user)> (define (commit-list repo)
  (let loop ((commit (commit-lookup repo
                                    (reference-target (repository-head repo))))
             (res '()))
    (match (commit-parents commit)
      (() (reverse res))
      ((head . tail)
       (loop head (cons head res))))))

scheme@(guix-user)> (define commits (commit-list repo))
scheme@(guix-user)> ,pp (take commits 5)
$1 = (#<git-commit 2639a99cf31e3ce2970645badf11f15679c893b5>
 #<git-commit f769ad12f1b7834a5fb6c870a6737d2eea495744>
 #<git-commit 8f330aebee504269d4d7188daa85e95503f71888>
 #<git-commit f765577dec0340d035021d030f17b54a3a5fd6b1>
 #<git-commit 72e3614666b8ffb7ecc568cbf4ba18874b9d8750>)
scheme@(guix-user)> cache
$2 = 
"/home/simon/.cache/guix/checkouts/pjmkglp4t7znuugeurpurzikxq3tnlaywmisyr27shj7apsnalwq"
scheme@(guix-user)> ,q

$ 
repo=/home/simon/.cache/guix/checkouts/pjmkglp4t7znuugeurpurzikxq3tnlaywmisyr27shj7apsnalwq
$ git -C $repo log --oneline | head -n6
91e35e32a4 gnu: fcitx5-chinese-addons: Remove stale build steps.
2639a99cf3 gnu: fcitx5-lua: Remove stale build steps.
f769ad12f1 gnu: toybox: Cross compile.
8f330aebee gnu: busybox: Update to 1.32.0.
f765577dec gnu: Add emacs-webpaste.
72e3614666 gnu: emacs-elpher: Mention gemini in synopsis and description.
--8<---------------cut here---------------end--------------->8---

Well, ’commit-list’ is far from perfect because all the log is traversed
and the list reversed, aside that the first commit is not captured,
etc. But I hope you get the idea.  It is a starting point to implement a
draft of:

  guix git log --oneline


Cheers,
simon



reply via email to

[Prev in Thread] Current Thread [Next in Thread]