Skip to content

Commit

Permalink
add source-url configuration to dist.ini (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
skaji committed May 29, 2024
1 parent 0f50639 commit 3c6b83e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions dist.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name = App::Mi6
source-url = https://github.com/skaji/mi6.git

[ReadmeFromPod]
filename = lib/App/Mi6.rakumod
Expand Down
25 changes: 16 additions & 9 deletions lib/App/Mi6.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ method regenerate-meta($module, $module-file) {
provides => config("AutoScanPackages", "enabled", :default<true>) eq "false"
?? ($already<provides> || self.find-provides())
!! self.find-provides(),
source-url => $already<source-url> || find-source-url(),
source-url => find-source-url(),
resources => $already<resources> || [],
tags => $already<tags> || [],
license => $already<license> || guess-license(),
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -496,7 +499,11 @@ Yes. Use C<dist.ini>:
=begin code :lang<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:
Expand Down
2 changes: 2 additions & 0 deletions xt/01-actual.rakutest
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -97,6 +98,7 @@ my $tempdir = tempdir;
"Hello::World1" => "lib/Hello/World1.rakumod",
"Hello::World2" => "lib/Hello/World2.pm6",
};
is $meta<source-url>, "https://github.com/foo/bar.git";
}

{
Expand Down

0 comments on commit 3c6b83e

Please sign in to comment.