-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ADO to GitHub - ADO Work Item links #1228
Comments
I was able to reproduce this. It looks like GEI is generating links in the PR description back to the AzDO work items, but the format of the link is not what the AzDO Boards <-> GitHub Integration expects. If the link format in the GH PR was |
Thanks @dylan-smith and @ArinGhazarian for your input. Ive had a look but don't see where its putting those PR comments in. I assume it happens inside the GitHub CLI migration logic? I did try to see if I could work around this limitation by querying all the PRs in GitHub and then calling ADO REST APIs to add a link to the GitHub PR, but from the ADO side its not possible to programmatically patch work items with a GitHub link due to that being controlled by the ADO GitHub app (which has a token for the connection to GitHub). https://github.com/github/gh-gei/blob/main/src/ado2gh/Commands/ConfigureAutoLink/ConfigureAutoLinkCommandHandler.cs looks like it runs after the migration of the repo in order to configure the auto link for future PRs right? So I don't think modifying/adding to that would help unless I'm wrong. Is this an issue that needs to be raised against the GitHub CLI itself? |
👋 @WillEllis, Yes, this needs to be fixed in the backend since the actual repo migration happens in the GEI backend and the CLI just initiates it. I will create an issue to address this. |
Thanks @ArinGhazarian. In the meantime if anyone else has this issue, I have managed to work around this limitation right now by writing a script that after migration goes through all the migrated repos PRs, finds any that have "AzureDevOps/#" in the body and updates that piece of text to be "AB#". As pointed out by Dylan above, this is what the Azure Boards integration is expecting and it then does its thing and links all the PRs so they show in the ADO work items correctly. |
Hi @WillEllis, can you share this script? |
@evervondel here you go. Its a powershell script, and you'll need to fill out the few github details at the top.
|
kudos !!
…On Fri, Sep 20, 2024 at 9:24 PM Will Ellis ***@***.***> wrote:
@evervondel <https://github.com/evervondel> here you go
# Define GitHub repository information
$githubOrg = ""
$githubRepo = ""
$githubToken = ""
$pageSize = 100
# Function to call GitHub API to get pull requests
function Get-GitHubPullRequests {
$url = "https://api.github.com/repos/$githubOrg/$githubRepo/pulls?state=all&per_page=$pageSize"
$headers = @{
"Authorization" = "token $githubToken"
}
$pullRequests = @()
do {
$response = Invoke-WebRequest -Uri $url -Headers $headers
# Parse JSON response
$responseData = $response.Content | ConvertFrom-Json
# Output pull requests
$pullRequests += $responseData
# Check if there's another page
$nextPageUrl = $response.RelationLink.next
if ($nextPageUrl) {
$url = $nextPageUrl
} else {
# No more pages, exit loop
$url = $null
}
} while ($url)
return $pullRequests
}
# Function to update PR description in GitHub repository
function Update-GitHubPRDescription {
param(
[string]$prNumber,
[string]$updatedDescription
)
$url = "https://api.github.com/repos/$githubOrg/$githubRepo/pulls/$prNumber"
$headers = @{
"Authorization" = "token $githubToken"
"Content-Type" = "application/json"
}
$body = @{
"body" = $updatedDescription
} | ConvertTo-Json
Invoke-RestMethod -Uri $url -Method Patch -Headers $headers -Body $body
}
# Get all pull requests from GitHub repository
$pullRequests = Get-GitHubPullRequests
# Loop through each pull request
foreach ($pullRequest in $pullRequests) {
$prNumber = $pullRequest.number
$prBody = $pullRequest.body
# Check if the PR body contains the string "AzureDevOps#"
if ($prBody -like "*AzureDevOps/#*") {
# Update the PR body by replacing "AzureDevOps#" with "AB#"
$updatedDescription = $prBody -replace "AzureDevOps/#", "AB#"
Write-Host "Updating description for PR $prNumber"
# Call function to update the PR description
Update-GitHubPRDescription -prNumber $prNumber -updatedDescription $updatedDescription
}
}
—
Reply to this email directly, view it on GitHub
<#1228 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEVNO32XNVEM422AQKABGJ3ZXRY7PAVCNFSM6AAAAABDTP3BYKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNRUGQZTSOBZGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Description
I've performed a trial run of migration from Azure DevOps Repos to GitHub and have a query around Work Item links. According to https://docs.github.com/en/migrations/using-github-enterprise-importer/migrating-from-azure-devops-to-github-enterprise-cloud/about-migrations-from-azure-devops-to-github-enterprise-cloud#data-that-is-migrated
Work items links on pull requests are migrated. This is a pretty key feature as we have many pull requests with the linked to many different work items with Azure DevOps Boards.
However when I ran the test work items ended up like this:
The pull request not found here is because ado2gh has disabled the ADO repo. But with the Work item links on PRs being migrated to me implies I should see GitHub PR links on this work item, like https://learn.microsoft.com/en-gb/azure/devops/boards/github/link-to-from-github?view=azure-devops#view-or-open-links-from-the-development-section
I've poked around a bit but cant see what I may have done wrong. Is this an issue with the migrator?
Reproduction Steps
The text was updated successfully, but these errors were encountered: