Skip to content

Allow doing testmerges from different repositories for forks. - #2431

Open
misleadingname wants to merge 5 commits into
tgstation:devfrom
misleadingname:dev
Open

Allow doing testmerges from different repositories for forks.#2431
misleadingname wants to merge 5 commits into
tgstation:devfrom
misleadingname:dev

Conversation

@misleadingname

@misleadingname misleadingname commented Feb 14, 2026

Copy link
Copy Markdown

🆑 REST API
Added support for performing test merges from different repositories, enabling fork workflows that track upstream PRs.
/:cl:

🆑 Nuget: API
Exposed support for cross-repository test merges.
/:cl:

🆑 Nuget: Client
Added client support for initiating cross-repository test merges.
/:cl:

Really useful for forks that are really close to their upstream, allows to pull in and use test merges from their upstream PRs that would either need to be manually mirrored or merged in. Mostly a huge QoL change.

@tgstation-server-ci

Copy link
Copy Markdown
Contributor

Thank you for contributing to tgstation-server! The CI Pipeline workflow requires repository secrets and will not run without approval. Maintainers can add the CI Cleared label to allow it to run. Note that any changes to ci-security.yml and ci-pipeline.yml will not be reflected.

@tgstation-server-ci tgstation-server-ci Bot added size/XXL CI Approval Required CI Pipeline execution blocked. Maintainers, apply the "CI Cleared" label to allow execution labels Feb 14, 2026

@Cyberboss Cyberboss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Needs minor version bumps to core, api, api library, and client in build/Version.props.
  • Needs a changelog entry for REST API, Nuget: Api, and Nuget: Client. Also remove that "Categories" entry you have now.
  • Needs down migration selection based on previous server version. (The tests are going to complain about this).
  • Fork https://github.com/Cyberboss/common_core and open a pull request on that fork. Then add tests to RepositoryTest.TestMergeTests.
  • This is going to need a new RepositoryRights entry (i.e. ForkTestMerges) that needs checking in RepositoryController.cs where test merges are added if TestMergeParameters.SourceRepository is set.

}

/// <inheritdoc />
public (string owner, string name) GetRepositoryOwnerAndName(TestMergeParameters parameters)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PascalCase for named tuples please

var numberMatch = testRevInfo.PrimaryTestMerge.Number == testTestMerge.Number;
if (!numberMatch)
return false;
var numberMatch = testRevInfo.PrimaryTestMerge.Number == testTestMerge.Number;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation gone wonky here

@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Format with tabs not spaces on all the migration files.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log message should be changed if it's from a separate remote

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both these branch names should be changed if a separate remote is in use. Which means IGitRemoteFeatures.TestMergeLocalBranchNameFormatter probably needs changing to a function

logger.LogTrace("Fetching refspec {refSpec}...", refSpec);

var (owner, name) = gitRemoteFeatures.GetRepositoryOwnerAndName(testMergeParameters);
var remote = libGitRepo.Network.Remotes.First();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of repository code assumes there is ever only one remote and since we don't know if it's deterministically ordered or not we need to check every place it's used and change it to refer to origin by name.

This one for example is no longer valid after the addition of an extra remote.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IGitRemoteFeatures.TestMergeRefSpecFormatter also needs to become a function of source repository

public int Number { get; set; }

/// <summary>
/// The source repository of the test merge. If not specified, the repository the server is configured to use will be used.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// The source repository of the test merge. If not specified, the repository the server is configured to use will be used.
/// The source repository slug of the test merge. If not specified, the repository the server is configured to use will be used.

.MapMySqlTextField<TestMerge>(x => x.BodyAtMerge)
.MapMySqlTextField<TestMerge>(x => x.Comment)
.MapMySqlTextField<TestMerge>(x => x.TargetCommitSha)
.MapMySqlTextField<TestMerge>(x => x.SourceRepository)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This list is for prior migrations and shouldn't be necessary here. Note that removing it will require you to regenerate the migrations.

@Cyberboss Cyberboss self-assigned this Feb 14, 2026
@Cyberboss Cyberboss added this to the v6.20.0 milestone Feb 14, 2026
@Cyberboss Cyberboss added Feature New functionality REST The JSON REST API for server control Area: Repository With regard to managing the git repository Migration Requires or performs a database migration CI Cleared Apply this to a pull request from a fork to allow it to run the CI suite labels Feb 14, 2026
@tgstation-server-ci tgstation-server-ci Bot removed the CI Approval Required CI Pipeline execution blocked. Maintainers, apply the "CI Cleared" label to allow execution label Feb 14, 2026
EventType.RepoAddTestMerge,
new List<string?>
{
testMergeParameters.Number.ToString(CultureInfo.InvariantCulture),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An additional parameter should be added to EventType.RepoAddTestMerge with the source repository if it's present. Documentation on the enum will also need updating

@tgstation-server-ci tgstation-server-ci Bot added CI Approval Required CI Pipeline execution blocked. Maintainers, apply the "CI Cleared" label to allow execution and removed CI Cleared Apply this to a pull request from a fork to allow it to run the CI suite labels Feb 14, 2026
@tgstation-server-ci tgstation-server-ci Bot added CI Approval Required CI Pipeline execution blocked. Maintainers, apply the "CI Cleared" label to allow execution and removed CI Approval Required CI Pipeline execution blocked. Maintainers, apply the "CI Cleared" label to allow execution labels Feb 14, 2026
@misleadingname

Copy link
Copy Markdown
Author

I really hope I did the changelog thing properly, also it's my first time actually doing a PR like that; so apologies if I did something wrong!

@Cyberboss Cyberboss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, was pretty busy this weekend

() =>
{
var remote = libGitRepo.Network.Remotes.First();
var remote = libGitRepo.Network.Remotes["origin"];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this a class const string please.

@misleadingname misleadingname Mar 8, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's actually unused so I'll get rid of the instance of this one, you probably meant all of those? Also I don't really get what you mean by making it a const string; as in make the remotes a string and not Remotes?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like

class Repository {
  const string DefaultRemoteName = "origin";
...

and then reference that instead of copying "origin" everywhere.

| RepositoryRights.UpdateBranch
| RepositoryRights.ChangeSubmoduleUpdate)]
| RepositoryRights.ChangeSubmoduleUpdate
| RepositoryRights.OffRepoTestMerges)]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd undo this change, OffRepoTestMerges by itself shouldn't grant proper access to this method. The MergePullRequest handles that.

@Cyberboss Cyberboss added the CI Cleared Apply this to a pull request from a fork to allow it to run the CI suite label Feb 17, 2026
@tgstation-server-ci tgstation-server-ci Bot removed the CI Approval Required CI Pipeline execution blocked. Maintainers, apply the "CI Cleared" label to allow execution label Feb 17, 2026
@misleadingname

Copy link
Copy Markdown
Author

Excuse the big delay, my primary computer broke and I had to wait for parts to arrive.

@tgstation-server-ci tgstation-server-ci Bot added CI Approval Required CI Pipeline execution blocked. Maintainers, apply the "CI Cleared" label to allow execution and removed CI Cleared Apply this to a pull request from a fork to allow it to run the CI suite labels Mar 9, 2026
@misleadingname

Copy link
Copy Markdown
Author

bump

@Cyberboss

Cyberboss commented Mar 24, 2026 via email

Copy link
Copy Markdown
Member

@Cyberboss Cyberboss added the CI Cleared Apply this to a pull request from a fork to allow it to run the CI suite label Mar 30, 2026
@Cyberboss

Copy link
Copy Markdown
Member

Sorry, cleared the tests

@tgstation-server-ci tgstation-server-ci Bot removed the CI Approval Required CI Pipeline execution blocked. Maintainers, apply the "CI Cleared" label to allow execution label Mar 30, 2026
Comment thread src/Tgstation.Server.Api/Rights/RepositoryRights.cs Outdated
Co-authored-by: Jordan Dominion <jordanhcbrown+github@gmail.com>
@tgstation-server-ci tgstation-server-ci Bot added CI Approval Required CI Pipeline execution blocked. Maintainers, apply the "CI Cleared" label to allow execution and removed CI Cleared Apply this to a pull request from a fork to allow it to run the CI suite labels Apr 13, 2026
@Cyberboss Cyberboss added the CI Cleared Apply this to a pull request from a fork to allow it to run the CI suite label Apr 14, 2026
@tgstation-server-ci tgstation-server-ci Bot removed the CI Approval Required CI Pipeline execution blocked. Maintainers, apply the "CI Cleared" label to allow execution label Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Repository With regard to managing the git repository CI Cleared Apply this to a pull request from a fork to allow it to run the CI suite Feature New functionality Migration Requires or performs a database migration REST The JSON REST API for server control size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants