Skip to content

Commit

Permalink
Fix working with non-master main branches
Browse files Browse the repository at this point in the history
Previously 'master' was hardcoded. Now the main branch name is
configurable.
  • Loading branch information
patrickbkr committed Apr 26, 2023
1 parent f577910 commit 29bce4a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
3 changes: 3 additions & 0 deletions config-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@ projects:
rakudo:
project: rakudo
repo: rakudo
main: main
slug: rakudo/rakudo
install-id: 20243470
nqp:
project: Raku
repo: nqp
main: main
slug: Raku/nqp
install-id: 20243470
moar:
project: MoarVM
repo: MoarVM
main: master
slug: MoarVM/MoarVM
install-id: 20243470

Expand Down
2 changes: 2 additions & 0 deletions lib/Config.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class ConfigProject {
has $.project;
has $.repo;
has $.slug;
has $.main;
has $.repo-url;
has $.install-id;

Expand All @@ -12,6 +13,7 @@ class ConfigProject {
project => %config<project>,
repo => %config<repo>,
slug => %config<project> ~ "/" ~ %config<repo>,
main => %config<main>,
repo-url => %config<repo-url>,
install-id => %config<install-id>,
;
Expand Down
22 changes: 11 additions & 11 deletions lib/SourceArchiveCreator.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -121,26 +121,26 @@ method create-archive(SourceSpec $source-spec --> Str) {
}

my @shas;
for $!rakudo-dir, $source-spec.rakudo-git-url, $source-spec.rakudo-commit-sha,
$!nqp-dir, $source-spec.nqp-git-url, $source-spec.nqp-commit-sha,
$!moar-dir, $source-spec.moar-git-url, $source-spec.moar-commit-sha
-> $repo-dir, $remote, $commit {
for $!rakudo-dir, $source-spec.rakudo-git-url, $source-spec.rakudo-commit-sha, config.projects.rakudo.main,
$!nqp-dir, $source-spec.nqp-git-url, $source-spec.nqp-commit-sha, config.projects.nqp.main,
$!moar-dir, $source-spec.moar-git-url, $source-spec.moar-commit-sha, config.projects.moar.main
-> $repo-dir, $remote, $commit, $main {
debug "SourceArchiveCreator: working on " ~ $remote ~ " " ~ $commit;
my $tmp-branch = 'tmp-branch';

run(qw|git remote rm foobar|,
run(qw|git remote rm|, $tmp-branch,
:cwd($repo-dir), :merge).so;

validate run qw|git remote add foobar|, $remote,
validate run qw|git remote add|, $tmp-branch, $remote,
:cwd($repo-dir), :merge;

#validate run qw|git fetch foobar|, |($.fetch-ref ?? ("+refs/" ~ $.fetch-ref ~ ":refs/remotes/" ~ $.fetch-ref,) !! ()),
validate run qw|git fetch foobar|,
#validate run qw|git fetch|, $tmp-branch, |($.fetch-ref ?? ("+refs/" ~ $.fetch-ref ~ ":refs/remotes/" ~ $.fetch-ref,) !! ()),
validate run qw|git fetch|, $tmp-branch,
:cwd($repo-dir), :merge;

# TODO no hard coded master branch.
my $to-use = $commit eq 'LATEST' ?? 'foobar/master' !! $commit;
my $ref = $commit eq 'LATEST' ?? "$tmp-branch/$main" !! $commit;

validate run qw|git reset --hard|, $to-use,
validate run qw|git reset --hard|, $ref,
:cwd($repo-dir), :merge;

# updating submodules
Expand Down
1 change: 0 additions & 1 deletion t/GitHubInterface.rakutest
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ check-mock($processor,
$_.number == 3
&& $_.user-url eq "https://github.com/patrickbkr/GitHub-API-Testing/pull/3"
&& $_.comments[0].body eq "Some description."
&& $_.head-url eq "https://github.com/patrickbkr/GitHub-API-Testing.git"
&& $_.base-url eq "https://github.com/patrickbkr/GitHub-API-Testing.git"
&& $_.head-branch eq "feature-branch-1"
&& $_.commit-task.commit-sha eq "f2b9e0fca8ad20c14bdc188240918720613d2cee"
Expand Down
3 changes: 3 additions & 0 deletions t/data/config-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@ projects:
rakudo:
project: rakudo
repo: rakudo
main: main
repo-url: https://github.com/rakudo/rakudo.git
install-id: 20243470
nqp:
project: Raku
repo: nqp
main: main
repo-url: https://github.com/nqp/nqp.git
install-id: 20243470
moar:
project: MoarVM
repo: MoarVM
main: master
repo-url: https://github.com/MoarVM/MoarVM.git
install-id: 20243470

Expand Down

0 comments on commit 29bce4a

Please sign in to comment.