From: Magali <magalilemes00@gmail.com>
To: zimoun <zimon.toutoune@gmail.com>,
"Gábor Boskovits" <boskovits@gmail.com>
Cc: Guix Devel <guix-devel@gnu.org>, Mathieu Othacehe <othacehe@gnu.org>
Subject: Re: [outreachy] Walk through the Git history (guix git {authenticate,log})
Date: Tue, 15 Dec 2020 12:20:09 -0300 [thread overview]
Message-ID: <c333cabd-dbe4-9718-56e8-64e03ee1024d@gmail.com> (raw)
In-Reply-To: <86lfe3fc0t.fsf@gmail.com>
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
next prev parent reply other threads:[~2020-12-15 15:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-11 17:41 [outreachy] Walk through the Git history (guix git {authenticate, log}) zimoun
2020-12-11 19:01 ` [outreachy] Walk through the Git history (guix git {authenticate,log}) Magali
2020-12-12 12:24 ` zimoun
2020-12-12 17:24 ` Magali
2020-12-12 17:49 ` [outreachy] Walk through the Git history zimoun
2020-12-14 10:20 ` Ludovic Courtès
2020-12-15 15:20 ` Magali [this message]
2020-12-16 9:35 ` [outreachy] Walk through the Git history (guix git {authenticate,log}) zimoun
2020-12-18 15:34 ` Ludovic Courtès
2020-12-19 3:18 ` Magali
2020-12-12 8:42 ` Mathieu Othacehe
2020-12-12 12:10 ` zimoun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c333cabd-dbe4-9718-56e8-64e03ee1024d@gmail.com \
--to=magalilemes00@gmail.com \
--cc=boskovits@gmail.com \
--cc=guix-devel@gnu.org \
--cc=othacehe@gnu.org \
--cc=zimon.toutoune@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).