Skip to content

Instantly share code, notes, and snippets.

@bgavrilMS
Last active January 17, 2024 20:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bgavrilMS/c5c1844796f2487beb21599ff4bb014c to your computer and use it in GitHub Desktop.
Save bgavrilMS/c5c1844796f2487beb21599ff4bb014c to your computer and use it in GitHub Desktop.
Clone GitHub issue cross MSAL repos
# 1. One time setup: install GH CLI https://cli.github.com/
# 2. Update $issue_to_clone and $target_repos variables
# 3. Manually update the project if needed (e.g. Customer Trust). Labels should be automatically cloned.
# Config - step 1
$issue_to_clone = "https://github.com/AzureAD/microsoft-authentication-library-for-java/issues/757"
$repo_java = 'https://github.com/AzureAD/microsoft-authentication-library-for-java/'
$repo_go = 'https://github.com/AzureAD/microsoft-authentication-library-for-go/'
$repo_py = 'https://github.com/AzureAD/microsoft-authentication-library-for-python/'
$repo_js = 'https://github.com/AzureAD/microsoft-authentication-library-for-js/'
$repo_android = 'https://github.com/AzureAD/microsoft-authentication-library-for-android/'
$repo_ios = 'https://github.com/AzureAD/microsoft-authentication-library-for-objc/'
$repo_cpp = 'https://github.com/AzureAD/microsoft-authentication-library-for-cpp/'
$repo_net = "https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/"
$target_repos = @($repo_net, $repo_py)
# Script logic
$auth_status_response = (gh auth status 2>&1) | Out-String
Write-Host "Logged in status: " $auth_status_response
if ($auth_status_response -like "*not logged in*")
{
Write-Host "Logging in..."
# Important: this is itneractive, just follow the commands
gh auth login -p https -h GitHub.com -w
}
# parse issue_to_clone into issue number and repo
$issue_to_clone_number = $issue_to_clone.Split("/")[-1]
$issue_to_clone_repo = $issue_to_clone.Split("/")[0..4] -join "/"
$originalIssue = (gh issue view $issue_to_clone_number -R $issue_to_clone_repo --json title,body,labels,url 2>&1) | Out-String | ConvertFrom-Json
$labels = $originalIssue.labels | ForEach-Object { """" + "$($_.name)" + """" }
$labelString = $labels -join ","
$body = $originalIssue.body + "`n`n ### Original issue: `n" + $originalIssue.url
#-p $repo_java.CTProject
foreach ($repo in $target_repos)
{
Write-Host "Creating issue in " $repo.Url
gh issue create -R $repo -t $originalIssue.title -b $body -l $labelString -w
}
@rayluo
Copy link

rayluo commented Jan 17, 2024

What is the significance of the CTProject = 'MSAL Java Customer Trust' line? There are some copy-and-paste error currently. @bgavrilMS

@bgavrilMS
Copy link
Author

Not currently used. I wanted to automate assigning an issue to the CT project associated with the repo.

@bgavrilMS
Copy link
Author

What is the significance of the CTProject = 'MSAL Java Customer Trust' line? There are some copy-and-paste error currently. @bgavrilMS

Updated, pls try again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment