~sircmpwn/sr.ht-discuss

6 4

Import GitLab issues?

Details
Message ID
<CZTSEI98538T.2UC3NBY2WBZ5G@cepl.eu>
DKIM signature
pass
Download raw message
Hi,

did anybody created a script converting GitLab issues (either
via API or exported NDJSON file) to todo.sr.ht? I am planning
to consolidate all my projects at SourceHut and I would need to
transfer my issues as well.

Best,

Matěj

-- 
http://matej.ceplovi.cz/blog/, @mcepl@floss.social
GPG Finger: 3C76 A027 CA45 AD70 98B5  BC1D 7920 5802 880B C9D8
 
The truth is a beautiful and terrible thing, and should therefore
be treated with caution.
  -- Albus Dumbledore
Details
Message ID
<CZZ81QNYBA6X.28WILM7WAC2LA@disroot.org>
In-Reply-To
<CZTSEI98538T.2UC3NBY2WBZ5G@cepl.eu> (view parent)
DKIM signature
pass
Download raw message
Hi Matěj,

On Fri Mar 15, 2024 at 10:22 AM NZDT, Matěj Cepl wrote:
> Hi,
>
> did anybody created a script converting GitLab issues (either
> via API or exported NDJSON file) to todo.sr.ht? I am planning
> to consolidate all my projects at SourceHut and I would need to
> transfer my issues as well.

Due to the lack of replies on this thread I would say most likely
not. However it should be pretty simple to create a shell script to do
what you need. You can utilise jq to parse the JSON in the export file
and use a command line mail utility [1] to create a new ticket on
todo.sr.ht using its email interface [2].

Just repeat that process for each ticket in your database and you
should be good to go. :)

 ~Jeremy

[1] I've written an ad-hoc mail utility which can be useful in times
    like these, see <https://sr.ht/~jeremy/mal>. There are also other
    tools available like msmtp which may require more configuration.
[2] todo.sr.ht allows creating tickets through the use of email
    messages, see <https://man.sr.ht/todo.sr.ht/#email-access>.
Details
Message ID
<CZZBALP4VN46.3F9Q54SXCP5MA@cepl.eu>
In-Reply-To
<CZZ81QNYBA6X.28WILM7WAC2LA@disroot.org> (view parent)
DKIM signature
pass
Download raw message
On Thu Mar 21, 2024 at 7:41 AM CET, Jeremy Baxter wrote:
> Due to the lack of replies on this thread I would say most likely
> not. However it should be pretty simple to create a shell script to do
> what you need. You can utilise jq to parse the JSON in the export file
> and use a command line mail utility [1] to create a new ticket on
> todo.sr.ht using its email interface [2].

What’s the difference between mal and plain ol’ mailx(1) (yes,
it has now SMTP client as well)?

> Just repeat that process for each ticket in your database and you
> should be good to go. :)

That’s probably what I will do.

> [2] todo.sr.ht allows creating tickets through the use of email
>     messages, see <https://man.sr.ht/todo.sr.ht/#email-access>.

Oh, thank you for this one! That’s quite interesting.

Matěj
-- 
http://matej.ceplovi.cz/blog/, @mcepl@floss.social
GPG Finger: 3C76 A027 CA45 AD70 98B5  BC1D 7920 5802 880B C9D8
 
Be kind, for everyone you meet is fighting a hard battle.
  -- Ian MacLaren
Details
Message ID
<HfsS7XVltUznIazMUrozlcoEg7mFzQckVwtC4w9uWoX8d94A6sIvfs4LHMBlk-RE1LJivJbGKLOQ-9yGg3zTJIL5jUyzMLAkRkTcXiCyRt0=@emersion.fr>
In-Reply-To
<CZTSEI98538T.2UC3NBY2WBZ5G@cepl.eu> (view parent)
DKIM signature
pass
Download raw message
I wrote a small tool for GitHub → sr.ht [1]. Maybe it can be hacked and
adapted to GitLab without too much pain (or maybe it can be useful just
as reference).

[1]: https://sr.ht/~emersion/gh2srht/
Details
Message ID
<CZZIGGVI12JX.30F0UBNWN7KOJ@cepl.eu>
In-Reply-To
<CZZ81QNYBA6X.28WILM7WAC2LA@disroot.org> (view parent)
DKIM signature
pass
Download raw message
On Thu Mar 21, 2024 at 7:41 AM CET, Jeremy Baxter wrote:
> Due to the lack of replies on this thread I would say most likely
> not. However it should be pretty simple to create a shell script to do
> what you need. You can utilise jq to parse the JSON in the export file
> and use a command line mail utility [1] to create a new ticket on
> todo.sr.ht using its email interface [2].

I was playing with jq a bit, for example this (fish shell):

    for i in (seq 3 10)
        jq -r '.['$i'] | .description' <issues.json|mail -s (jq -r '.['$i'] | .title' <issues.json) ~mcepl/json_diff@todo.sr.ht
    end

But I guess something got broken with quoting so not all tickets were created. Then I created this Python script:

    #!/usr/bin/python3

    import json
    import os.path
    import pprint
    import smtplib
    import sys

    if len(sys.argv) < 2:
        print(f"sys.argv: {sys.argv}")
        sys.exit(1)

    out = {}

    INP = sys.argv[1]
    if not os.path.exists(INP):
        sys.exit(2)

    with open(INP) as inf:
        input = sorted(json.load(inf), key=lambda item: item['iid'])

    for issue in input:
        id = issue['iid']
        out[id] = {
            'title': issue['title'],
            'desc': issue['description'],
            'status': issue['state'],
            'comments': []
        }
        for note in issue['notes']:
            out[id]['comments'].append({
                'text': note['note']
            })

    fromaddr="mcepl@cepl.eu"
    toaddrs=('~mcepl/json_diff@todo.sr.ht',)

    with smtplib.SMTP('redcrew.org', port=587) as smtp:
        smtp.starttls()
        smtp.login("verysecretlogin", "verysecretpassword")
        for key, iss in out.items():
            msg = ("From: %s\r\nTo: %s\r\n\r\n"
                   % (fromaddr, ", ".join(toaddrs)))
            if iss['desc'] is not None:
                msg += iss['desc']
        
        smtp.sendmail("mcepl@cepl.eu", "~mcepl/json_diff@todo.sr.ht",msg)

but then I was too lazy to debug it and just created (with
loosing a lot of metadata) those tickets via copy&paste. If
anybody wants to play with it, example JSON file is at
https://paste.sr.ht/~mcepl/f5b70a05e4fcf12352f1c4fd86221c2fc29c4a42.

Best,

Matěj

-- 
http://matej.ceplovi.cz/blog/, @mcepl@floss.social
GPG Finger: 3C76 A027 CA45 AD70 98B5  BC1D 7920 5802 880B C9D8
 
Whenever Christ our life is revealed, then also you will be
revealed with Him in glory.
    -- Colossians 3:4 (Green’s Literal Translation)
Details
Message ID
<CZZRKGE36RH1.2NPM4UOJLJGWE@disroot.org>
In-Reply-To
<CZZBALP4VN46.3F9Q54SXCP5MA@cepl.eu> (view parent)
DKIM signature
pass
Download raw message
On Thu Mar 21, 2024 at 10:14 PM NZDT, Matěj Cepl wrote:
> What’s the difference between mal and plain ol’ mailx(1) (yes,
> it has now SMTP client as well)?

I've never used mailx before, but reading the Heirloom man page for it
gives me the impression that it does the same thing as mal with more
features (e.g. you can use -c to supply a Cc address while with mal
you have to use a custom header with -H). If you can properly send
email with it then it'll work.

> > Just repeat that process for each ticket in your database and you
> > should be good to go. :)
>
> That’s probably what I will do.

Awesome, good luck!

 ~Jeremy
Details
Message ID
<20240503023800.5bd2436c@khumba.net>
In-Reply-To
<CZTSEI98538T.2UC3NBY2WBZ5G@cepl.eu> (view parent)
DKIM signature
pass
Download raw message
Hi Matěj,

On Thu, 14 Mar 2024 22:22:38 +0100
Matěj Cepl <mcepl@cepl.eu> wrote:

> Hi,
> 
> did anybody created a script converting GitLab issues (either
> via API or exported NDJSON file) to todo.sr.ht? I am planning
> to consolidate all my projects at SourceHut and I would need to
> transfer my issues as well.

I am also in the process of migrating to Sourcehut, and here's what I
wrote to go the NDJSON route.  It's quick and dirty but works well
enough for me:

https://git.sr.ht/~khumba/lazygl2srht

Here's a sample project I have run it against:

https://todo.sr.ht/~khumba/hoppy

Probably too late for you now though I would guess.

Cheers,
Bryan
Reply to thread Export thread (mbox)