From 3c6b83e6433e9c20ce4734183f46234e78e72112 Mon Sep 17 00:00:00 2001 From: Shoichi Kaji Date: Thu, 30 May 2024 08:48:37 +0900 Subject: [PATCH] add source-url configuration to dist.ini (#181) --- README.md | 6 +++++- dist.ini | 1 + lib/App/Mi6.rakumod | 25 ++++++++++++++++--------- xt/01-actual.rakutest | 2 ++ 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index fed5d00..eed5421 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,11 @@ Yes. Use `dist.ini`: ```ini ; dist.ini -name = Your-Module-Name +name = Your::Module::Name + +; mi6 automatically guesses source-url by `git remote -v`. +; if it doesn't work for some reasons, you can specify source-url: +source-url = https://github.com/you/Your-Module-Name.git [ReadmeFromPod] ; if you want to disable generating README.md from main module's pod, then: diff --git a/dist.ini b/dist.ini index 9b91a7a..1e23802 100644 --- a/dist.ini +++ b/dist.ini @@ -1,4 +1,5 @@ name = App::Mi6 +source-url = https://github.com/skaji/mi6.git [ReadmeFromPod] filename = lib/App/Mi6.rakumod diff --git a/lib/App/Mi6.rakumod b/lib/App/Mi6.rakumod index 005d4be..966060b 100644 --- a/lib/App/Mi6.rakumod +++ b/lib/App/Mi6.rakumod @@ -278,7 +278,7 @@ method regenerate-meta($module, $module-file) { provides => config("AutoScanPackages", "enabled", :default) eq "false" ?? ($already || self.find-provides()) !! self.find-provides(), - source-url => $already || find-source-url(), + source-url => find-source-url(), resources => $already || [], tags => $already || [], license => $already || guess-license(), @@ -352,13 +352,16 @@ my $GIT-REMOTE-REGEXP = rx{^[ ]$}; sub find-source-url() { - my @line = mi6run("git", "remote", "-v", :out, :!err).out.lines(:close); - return "" unless @line; - my $url = gather for @line -> $line { - my ($name, $url) = $line.split(/\s+/); - if $name eq "origin" and $url { - take $url; - last; + my $url = config("_", "source-url"); + if !$url { + my @line = mi6run("git", "remote", "-v", :out, :!err).out.lines(:close); + return "" unless @line; + $url = gather for @line -> $line { + my ($name, $url) = $line.split(/\s+/); + if $name eq "origin" and $url { + take $url; + last; + } } } return "" unless $url; @@ -496,7 +499,11 @@ Yes. Use C: =begin code :lang ; dist.ini -name = Your-Module-Name +name = Your::Module::Name + +; mi6 automatically guesses source-url by `git remote -v`. +; if it doesn't work for some reasons, you can specify source-url: +source-url = https://github.com/you/Your-Module-Name.git [ReadmeFromPod] ; if you want to disable generating README.md from main module's pod, then: diff --git a/xt/01-actual.rakutest b/xt/01-actual.rakutest index c92fba5..7188690 100644 --- a/xt/01-actual.rakutest +++ b/xt/01-actual.rakutest @@ -82,6 +82,7 @@ my $tempdir = tempdir; "lib/Hello/World5.pm6".IO.spurt(""); "dist.ini".IO.spurt: q:to/EOF/; name = Hello::World + source-url = https://github.com/foo/bar.git [PruneFiles] filename = lib/Hello/World5.pm6 [MetaNoIndex] @@ -97,6 +98,7 @@ my $tempdir = tempdir; "Hello::World1" => "lib/Hello/World1.rakumod", "Hello::World2" => "lib/Hello/World2.pm6", }; + is $meta, "https://github.com/foo/bar.git"; } {