### ----------------------------------------------------
### -- Migration::RTtoGithub
### -- Licenses: Artistic-2.0
### -- Authors: Elizabeth Mattijsen
### -- File: lib/Migration/RTtoGithub.rakumod
### ----------------------------------------------------
### -- Chunk 10 of 10
31758,6396,131763,6397,131764,6398,131766,6399,131767,6400,131774,6401,131776,6402,131778,6403,131780,6404,131781,6405,131783,6406,131785,6407,131789,6408,131790,6409,131791,6410,131797,6411,131801,6412,131805,6414,131813,6415,131814,6416,131815,6417,131826,6418,131827,6419,131829,6420,131830,6421,131831,6422,131838,6423,131839,6413,131840,6424,131841,6425,131842,6426,131845,6427,131846,6428,131853,6429,131855,6430,131856,6431,131857,6432,131858,6434,131865,6435,131870,6436,131871,6437,131877,6438,131879,6439,131881,6440,131884,6441,131887,6442,131888,6443,131889,6444,131898,6445,131900,6446,131911,6447,131913,6433,131914,6448,131915,6449,131919,6450,131922,6451,131923,6452,131924,6454,131925,6455,131927,6456,131932,6457,131934,6458,131935,6459,131936,6460,131940,6461,131945,6462,131947,6463,131948,6464,131956,6465,131961,6466,131962,6467,131964,6468,131965,6469,131966,6470,131970,6471,131971,6472,131972,6473,131973,6474,131974,6476,131981,6453,131985,6477,131991,6478,131994,6479,131996,6480,131997,6481,131998,6482,132003,6483,132004,6484,132005,6485,132006,6486,132010,6487,132012,6488,132015,6489,132016,6490,132020,6491,132025,6475,132029,6492,132030,6493,132032,6494,132033,6495,132034,6496,132035,6497,132039,6498,132040,6499,132041,6500,132042,6501,132043,6502,132044,6503,132045,6504,132050,6505,132051,6506,132052,6507,132053,6508,132066,6509,132073,6510,132076,6511,132081,6512,132082,6513,132083,6514,132085,6516,132086,6517,132088,6518,132089,6519,132090,6520,132091,6521,132093,6522,132097,6523,132101,6524,132102,6525,132103,6526,132104,6527,132107,6528,132108,6515,132109,6529,132110,6530,132111,6531,132114,6532,132117,6533,132119,6535,132120,6536,132121,6537,132126,6538,132128,6539,132133,6540,132135,6541,132140,6542,132146,6543,132148,6544,132149,6545,132154,6546,132156,6547,132157,6548,132162,6549,132166,6550,132168,6551,132169,6534,132170,6552,132172,6553,132176,6555,132179,6556,132183,6557,132184,6558,132185,6559,132186,6560,132191,6561,132194,6562,132195,6563,132205,6564,132209,6565,132210,6566,132211,6554,132214,6567,132216,6568,132217,6569,132219,6570,132220,6571,132222,6572,132225,6573,132226,6574,132228,6575,132232,6576,132233,6577,132236,6578,132237,6579,132238,6580,132239,6581,132240,6582,132241,6583,132242,6584,132246,6585,132248,6586,132249,6587,132250,6588,132251,6589,132254,6590,132258,6591,132261,6592,132262,6593,132268,6594,132269,6595,132273,6596,132275,6597,132279,6598,132280,6599,132281,6600,132282,6601,132283,6602,132284,6603,132285,6604,132287,6605,132288,6606,132289,6607,132290,6608,132291,6609,132292,6610,132293,6611,132294,6612,132295,6613,132300,6614,132302,6615,132305,6616,132306,6617,132307,6618,132313,6619,132316,6620,132326,6621,132328,6622,132329,6623,132335,6624,132337,6625,132339,6626,132341,6627,132343,6628,132346,6629,132348,6630,132349,6631,132352,6632,132353,6633,132377,6634,132416,6635,132426,6636,132441,6637,132447,6638,132452,6639,132487,6640,132510,6641,132511,6642,132512,6643,132514,6644,132525,6645,132543,6646,132549,6647,132570,6648,132585,6649,132592,6650,132611,6651,132632,6652,132650,6653,132666,6654,132668,6655,132673,6657,132675,6658,132694,6659,132699,6660,132710,6661,132711,6662,132713,6663,132718,6664,132741,6665,132742,6666,132780,6667,132784,6668,132785,6669,132794,6670,132835,6671,132846,6672,132864,6673,132874,6674,132877,6675,132885,6676,132909,6677,132980,6656,132983,6678,133016,6679,133017,6680,133057,6681,133082,6682,133107,6683,133162,6684,133246,6685,133268,6686,133300,6687,133541,6688,133762,6689,133772,6690,133791,6691
).map: *.Str);

my constant %GH2RT = Map.new(%RT2GH.antipairs);

my sub GH(Str() $ticket) is export { %RT2GH{$ticket} }
my sub RT(Str() $issue)  is export { %GH2RT{$issue}  }

my sub URL(Str() $ticket, :$old) is export {
    if $old {
        "https://rt.perl.org/Ticket/Display.html?id=$ticket"
    }
    elsif %RT2GH{$ticket} -> $url {
       "https://github.com/Raku/old-issue-tracker/issues/$url"
    }
    else {
        my $proc = run <curl --head https://rt.perl.org/Ticket/Display.html?id=112148>, :out, :!err;
        if $proc.out.slurp.lines.first: *.starts-with("Location: ") -> $line {
            $line.substr(10)
        }
        else {
            URL $ticket, :old
        }
    }
}

=begin pod

=head1 NAME

Migration::RTtoGithub - mapping of old RT tickets to GitHub issues

=head1 SYNOPSIS

=begin code :lang<raku>

use Migration::RTtoGithub;

say GH(127016);  # 4921
say RT(4921);    # 127016

say URL(127016);        # https://github.com/Raku/old-issue-tracker/issues/4921
say URL(127016, :old);  # http://rt.perl.org/Ticket/Display.html?id=127016

=end code

=head1 DESCRIPTION

Migration::RTtoGithub is a small library that contains the information
for mapping old RT tickets for Perl 6 to Raku tickets on GitHub in the
Raku/old-issue-tracker repository.

=head1 SUBROUTINES

=head2 GH

=begin code :lang<raku>

say GH(127016);  # 4921

=end code

Return the number of the Github issue associated with the given RT
ticket number.

=head2 RT

=begin code :lang<raku>

say RT(4921);    # 127016

=end code

Return the number of the RT ticket associated with the given Github
issue number.

=head2 URL

=begin code :lang<raku>

say URL(127016);        # https://github.com/Raku/old-issue-tracker/issues/4921
say URL(127016, :old);  # http://rt.perl.org/Ticket/Display.html?id=127016

=end code

Return the URL of the Github issue for the given RT ticket if possible.
If there is no known mapping, then the URL of the RT ticket will be
returned: you can then use that to see if the original RT site will
redirect you to a Github issue or not.  You can also for the URL of
the original site to be returned by specifying the C<:old> named
argument.

=head1 AUTHOR

Elizabeth Mattijsen <liz@raku.rocks>

Source can be located at: https://github.com/lizmat/Migration-RTtoGithub .
Comments and Pull Requests are welcome.

If you like this module, or what I’m doing more generally, committing to a
L<small sponsorship|https://github.com/sponsors/lizmat/>  would mean a great
deal to me!

=head1 COPYRIGHT AND LICENSE

Copyright 2020, 2021, 2024 Elizabeth Mattijsen

This library is free software; you can redistribute it and/or modify it under
the Artistic License 2.0.

=end pod

# vim: expandtab shiftwidth=4


