From fc509744049c151e9b4cecff2350d5468f5f01a8 Mon Sep 17 00:00:00 2001 From: Matt Brzezinski Date: Thu, 12 Aug 2021 16:29:57 -0500 Subject: [PATCH 1/2] GH repo check the fork field --- Project.toml | 2 +- src/pull_requests.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 8c8555e7..cf65fbb7 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "CompatHelper" uuid = "aa819f21-2bde-4658-8897-bab36330d9b7" authors = ["Dilum Aluthge", "Brown Center for Biomedical Informatics", "contributors"] -version = "3.0.2" +version = "3.0.3" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" diff --git a/src/pull_requests.jl b/src/pull_requests.jl index 270075bc..793edd2b 100644 --- a/src/pull_requests.jl +++ b/src/pull_requests.jl @@ -35,7 +35,7 @@ function get_pull_requests( return @mock unique(paginated_prs) end -not_pr_fork(repo::GitHub.Repo, pr::GitHub.PullRequest) = repo == pr.head.repo +not_pr_fork(repo::GitHub.Repo, pr::GitHub.PullRequest) = !pr.head.repo.fork not_pr_fork(repo::GitLab.Project, pr::GitLab.MergeRequest) = repo.id == pr.project_id my_prs(username::String, pr::GitHub.PullRequest) = lower(pr.user.login) == lower(username) From 912dcf8bd0ec1ed51c06d18c7979a73e315d4473 Mon Sep 17 00:00:00 2001 From: Matt Brzezinski Date: Thu, 12 Aug 2021 16:41:40 -0500 Subject: [PATCH 2/2] Fixed unit tests for forked PRs --- test/patches.jl | 6 +++--- test/pull_requests.jl | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/patches.jl b/test/patches.jl index 047f57e4..6d682f9b 100644 --- a/test/patches.jl +++ b/test/patches.jl @@ -76,8 +76,8 @@ end gh_gpr_patch = @patch function CompatHelper.get_pull_requests( api::GitHub.GitHubAPI, repo::GitHub.Repo, state::String ) - origin_repo = GitHub.Repo(; id=1) - fork_repo = GitHub.Repo(; id=2) + origin_repo = GitHub.Repo(; id=1, fork=false) + fork_repo = GitHub.Repo(; id=2, fork=true) pr_from_origin = GitHub.PullRequest(; head=GitHub.Head(; repo=origin_repo), @@ -95,7 +95,7 @@ end gl_gpr_patch = @patch function CompatHelper.get_pull_requests( api::GitLab.GitLabAPI, repo::GitLab.Project, state::String ) - origin_repo = GitLab.Project(; id=1) + origin_repo = GitLab.Project(; id=1, fork=false) pr_from_origin = GitLab.MergeRequest(; project_id=1, author=GitLab.User(; username="foobar"), title="title" diff --git a/test/pull_requests.jl b/test/pull_requests.jl index eec666ab..ec5c0709 100644 --- a/test/pull_requests.jl +++ b/test/pull_requests.jl @@ -35,8 +35,8 @@ end @testset "no forks" begin @testset "GitHub" begin - origin_repo = GitHub.Repo(; id=1) - fork_repo = GitHub.Repo(; id=2) + origin_repo = GitHub.Repo(; id=1, fork=false) + fork_repo = GitHub.Repo(; id=2, fork=true) pr_from_origin = GitHub.PullRequest(; head=GitHub.Head(; repo=origin_repo), @@ -61,8 +61,8 @@ end end @testset "GitLab" begin - origin_repo = GitLab.Project(; id=1) - fork_repo = GitLab.Project(; id=2) + origin_repo = GitLab.Project(; id=1, fork=false) + fork_repo = GitLab.Project(; id=2, fork=true) pr_from_origin = GitLab.MergeRequest(; id=1, project_id=1, author=GitLab.User(; username=username), title="PR A" @@ -85,7 +85,7 @@ end @testset "only my prs" begin @testset "GitHub" begin - origin_repo = GitHub.Repo(; id=1) + origin_repo = GitHub.Repo(; id=1, fork=false) pr_from_me = GitHub.PullRequest(; head=GitHub.Head(; repo=origin_repo), @@ -110,7 +110,7 @@ end end @testset "GitLab" begin - origin_repo = GitLab.Project(; id=1) + origin_repo = GitLab.Project(; id=1, fork=false) pr_from_me = GitLab.MergeRequest(; id=1, project_id=1, author=GitLab.User(; username=username), title="PR A" @@ -134,7 +134,7 @@ end @testset "no forks and only my prs" begin @testset "GitHub" begin api = GitForge.GitHub.GitHubAPI() - repo = GitHub.Repo(; id=1) + repo = GitHub.Repo(; id=1, fork=false) apply(gh_gpr_patch) do prs = CompatHelper.get_pr_titles(api, repo, "foobar")