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: Magali
Subject: Re: [outreachy] Walk through the Git history (guix git {authenticate,log})
Date: Tue, 15 Dec 2020 12:20:09 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

Hello, I've been tweaking this piece of code below, trying to adapt it
so that it could get the latest commit into the commit list too, but I
haven't had success.

On 12/12/2020 09:24, zimoun wrote:
> --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


This is what I've been doing:

-------

$ 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)> (define cache (url-cache-directory (channel-url
%default-guix-channel)))
scheme@(guix-user)> cache
$1 =
"/home/magali/.cache/guix/checkouts/pjmkglp4t7znuugeurpurzikxq3tnlaywmisyr27shj7apsnalwq"
scheme@(guix-user)> (let* ((repo (repository-open cache))
         (latest-commit
          (commit-lookup repo (reference-target (repository-head repo)))))
    (let loop ((commit latest-commit)
               (res (list latest-commit)))
      (match (commit-parents commit)
             (() (reverse res))
             ((head . tail)
              (loop head (cons head res))))))
Segmentation fault (core dumped)
-------

I couldn't quite figure it out why I'm getting segfault. Any tips?


Magali





reply via email to

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