Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ Refer to the [official documentation](https://docs.github.com/en/migrations/usin

Refer to the [official documentation](https://docs.github.com/en/migrations/using-github-enterprise-importer/migrating-repositories-with-github-enterprise-importer/migrating-repositories-from-azure-devops-to-github-enterprise-cloud) for more details.

#### Cleaning Status Checks during Migration
When migrating from Azure DevOps, both branch policies and status checks are transferred to GitHub. However, many ADO status checks are not supported in GitHub. To clean status checks from GitHub branch protection rules after migration, use the `--clean-status-checks` option:

>`gh ado2gh migrate-repo --ado-org ORGNAME --ado-team-project PROJECTNAME --ado-repo REPONAME --github-org ORGNAME --github-repo REPONAME --clean-status-checks`

This option will:
- Complete the normal migration process (including transferring all branch policies)
- After migration completion, automatically remove status checks from the default branch's protection rule
- Preserve other branch protection settings like required reviewers, admin enforcement, etc.

**Note:** This is a post-migration cleanup step, so it only affects the final GitHub repository state and does not impact the migration data transfer itself.

### Bitbucket Server and Data Center to GitHub Usage
1. Create Personal Access Token for the target GitHub org (for more details on scopes needed refer to our [official documentation](https://docs.github.com/en/migrations/using-github-enterprise-importer/preparing-to-migrate-with-github-enterprise-importer/managing-access-for-github-enterprise-importer)).

Expand Down Expand Up @@ -89,11 +101,11 @@ Refer to the [official documentation](https://docs.github.com/en/migrations/usin

### Skipping version checks

When the CLI is launched, it logs if a newer version of the CLI is available. You can skip this check by setting the `GEI_SKIP_VERSION_CHECK` environment variable to `true`.
When the CLI is launched, it logs if a newer version of the CLI is available. You can skip this check by setting the `GEI_SKIP_VERSION_CHECK` environment variable to `true`.

### Skipping GitHub status checks

When the CLI is launched, it logs a warning if there are any ongoing [GitHub incidents](https://www.githubstatus.com/) that might affect your use of the CLI. You can skip this check by setting the `GEI_SKIP_STATUS_CHECK` environment variable to `true`.
When the CLI is launched, it logs a warning if there are any ongoing [GitHub incidents](https://www.githubstatus.com/) that might affect your use of the CLI. You can skip this check by setting the `GEI_SKIP_STATUS_CHECK` environment variable to `true`.

## Contributions

Expand Down
37 changes: 34 additions & 3 deletions src/Octoshift/Services/GithubApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ mutation startRepositoryMigration(
$lockSource: Boolean)";
var gql = @"
startRepositoryMigration(
input: {
input: {
sourceId: $sourceId,
ownerId: $ownerId,
sourceRepositoryUrl: $sourceRepositoryUrl,
Expand Down Expand Up @@ -456,7 +456,7 @@ mutation startOrganizationMigration (
$targetEnterpriseId: ID!,
$sourceAccessToken: String!)";
var gql = @"
startOrganizationMigration(
startOrganizationMigration(
input: {
sourceOrgUrl: $sourceOrgUrl,
targetOrgName: $targetOrgName,
Expand Down Expand Up @@ -1077,7 +1077,7 @@ mutation abortRepositoryMigration(
)";
var gql = @"
abortRepositoryMigration(
input: {
input: {
migrationId: $migrationId
})
{ success }";
Expand Down Expand Up @@ -1264,4 +1264,35 @@ private static CodeScanningAlertInstance BuildCodeScanningAlertInstance(JToken s
StartColumn = (int)scanningAlertInstance["location"]["start_column"],
EndColumn = (int)scanningAlertInstance["location"]["end_column"]
};

public virtual async Task<JObject> GetBranchProtection(string org, string repo, string branch)
{
var url = $"{_apiUrl}/repos/{org.EscapeDataString()}/{repo.EscapeDataString()}/branches/{branch.EscapeDataString()}/protection";

try
{
var response = await _client.GetAsync(url);
return JObject.Parse(response);
}
catch (HttpRequestException)
{
// Branch protection may not exist, return null
return null;
}
}

public virtual async Task UpdateBranchProtection(string org, string repo, string branch, object protection)
{
var url = $"{_apiUrl}/repos/{org.EscapeDataString()}/{repo.EscapeDataString()}/branches/{branch.EscapeDataString()}/protection";
await _client.PutAsync(url, protection);
}

public virtual async Task<IEnumerable<string>> GetBranches(string org, string repo)
{
var url = $"{_apiUrl}/repos/{org.EscapeDataString()}/{repo.EscapeDataString()}/branches";
var response = await _client.GetAsync(url);
var data = JArray.Parse(response);

return data.Select(x => (string)x["name"]);
}
}
Loading
Loading