Skip to content

Commit

Permalink
Merge branch 'main' into myao/sync_sb3
Browse files Browse the repository at this point in the history
# Conflicts:
#	eng/versioning/external_dependencies.txt
#	eng/versioning/version_client.txt
#	sdk/appconfiguration/azure-data-appconfiguration/pom.xml
#	sdk/communication/azure-communication-callautomation/pom.xml
#	sdk/communication/azure-communication-callingserver/pom.xml
#	sdk/communication/azure-communication-common/pom.xml
#	sdk/communication/azure-communication-identity/pom.xml
#	sdk/communication/azure-communication-jobrouter/pom.xml
#	sdk/communication/azure-communication-networktraversal/pom.xml
#	sdk/communication/azure-communication-phonenumbers/pom.xml
#	sdk/communication/azure-communication-rooms/pom.xml
#	sdk/communication/azure-communication-sms/pom.xml
#	sdk/containerregistry/azure-containers-containerregistry/pom.xml
#	sdk/core/azure-core-amqp-experimental/pom.xml
#	sdk/core/azure-core-amqp/pom.xml
#	sdk/core/azure-core-experimental/pom.xml
#	sdk/core/azure-core-http-jdk-httpclient/pom.xml
#	sdk/core/azure-core-http-netty/pom.xml
#	sdk/core/azure-core-http-okhttp/pom.xml
#	sdk/core/azure-core-http-vertx/pom.xml
#	sdk/core/azure-core-management/pom.xml
#	sdk/core/azure-core-perf/pom.xml
#	sdk/core/azure-core-serializer-avro-apache/pom.xml
#	sdk/core/azure-core-serializer-avro-jackson/pom.xml
#	sdk/core/azure-core-serializer-json-gson/pom.xml
#	sdk/core/azure-core-serializer-json-jackson/pom.xml
#	sdk/core/azure-core-test/pom.xml
#	sdk/core/azure-core-version-tests/pom.xml
#	sdk/core/azure-core/pom.xml
#	sdk/cosmos/azure-cosmos-benchmark/pom.xml
#	sdk/cosmos/azure-cosmos-dotnet-benchmark/pom.xml
#	sdk/cosmos/azure-cosmos-encryption/pom.xml
#	sdk/cosmos/azure-cosmos-spark_3_2-12/pom.xml
#	sdk/cosmos/azure-cosmos-tests/pom.xml
#	sdk/cosmos/azure-cosmos/pom.xml
#	sdk/e2e/pom.xml
#	sdk/eventgrid/azure-messaging-eventgrid/pom.xml
#	sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/pom.xml
#	sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-jedis/pom.xml
#	sdk/eventhubs/azure-messaging-eventhubs-stress/pom.xml
#	sdk/eventhubs/azure-messaging-eventhubs/pom.xml
#	sdk/identity/azure-identity/pom.xml
#	sdk/keyvault/azure-security-keyvault-administration/pom.xml
#	sdk/keyvault/azure-security-keyvault-certificates/pom.xml
#	sdk/keyvault/azure-security-keyvault-keys/pom.xml
#	sdk/keyvault/azure-security-keyvault-secrets/pom.xml
#	sdk/maps/azure-maps-elevation/pom.xml
#	sdk/maps/azure-maps-geolocation/pom.xml
#	sdk/maps/azure-maps-render/pom.xml
#	sdk/maps/azure-maps-route/pom.xml
#	sdk/maps/azure-maps-search/pom.xml
#	sdk/maps/azure-maps-timezone/pom.xml
#	sdk/maps/azure-maps-traffic/pom.xml
#	sdk/maps/azure-maps-weather/pom.xml
#	sdk/mixedreality/azure-mixedreality-authentication/pom.xml
#	sdk/monitor/azure-monitor-ingestion/pom.xml
#	sdk/remoterendering/azure-mixedreality-remoterendering/pom.xml
#	sdk/resourcemanager/azure-resourcemanager-resources/pom.xml
#	sdk/resourcemanagerhybrid/azure-resourcemanager-resources/pom.xml
#	sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml
#	sdk/schemaregistry/azure-data-schemaregistry-jsonschema/pom.xml
#	sdk/schemaregistry/azure-data-schemaregistry/pom.xml
#	sdk/search/azure-search-documents/pom.xml
#	sdk/servicebus/azure-messaging-servicebus-stress/pom.xml
#	sdk/servicebus/azure-messaging-servicebus/pom.xml
#	sdk/spring/CHANGELOG.md
#	sdk/spring/azure-spring-data-cosmos/pom.xml
#	sdk/spring/pipeline/spring-cloud-azure-supported-spring.json
#	sdk/spring/scripts/spring_boot_2.7.17_managed_external_dependencies.txt
#	sdk/spring/spring-cloud-azure-actuator-autoconfigure/pom.xml
#	sdk/spring/spring-cloud-azure-actuator/pom.xml
#	sdk/spring/spring-cloud-azure-appconfiguration-config-web/pom.xml
#	sdk/spring/spring-cloud-azure-appconfiguration-config/pom.xml
#	sdk/spring/spring-cloud-azure-autoconfigure/pom.xml
#	sdk/spring/spring-cloud-azure-feature-management-web/pom.xml
#	sdk/spring/spring-cloud-azure-feature-management/pom.xml
#	sdk/spring/spring-cloud-azure-integration-test-appconfiguration-config/pom.xml
#	sdk/spring/spring-cloud-azure-integration-tests/pom.xml
#	sdk/spring/spring-cloud-azure-starter-actuator/pom.xml
#	sdk/spring/spring-cloud-azure-starter-integration-eventhubs/pom.xml
#	sdk/spring/spring-cloud-azure-starter-integration-servicebus/pom.xml
#	sdk/spring/spring-cloud-azure-starter-integration-storage-queue/pom.xml
#	sdk/spring/spring-cloud-azure-starter-monitor-test/pom.xml
#	sdk/spring/spring-cloud-azure-starter-monitor/pom.xml
#	sdk/spring/spring-cloud-azure-starter-redis/pom.xml
#	sdk/spring/spring-cloud-azure-starter-servicebus-jms/pom.xml
#	sdk/spring/spring-cloud-azure-starter/pom.xml
#	sdk/spring/spring-cloud-azure-stream-binder-eventhubs-core/pom.xml
#	sdk/spring/spring-cloud-azure-stream-binder-eventhubs/pom.xml
#	sdk/spring/spring-cloud-azure-stream-binder-servicebus-core/pom.xml
#	sdk/spring/spring-cloud-azure-stream-binder-servicebus/pom.xml
#	sdk/spring/spring-messaging-azure-eventhubs/pom.xml
#	sdk/spring/spring-messaging-azure-servicebus/pom.xml
#	sdk/spring/spring-messaging-azure-storage-queue/pom.xml
#	sdk/spring/spring-messaging-azure/pom.xml
#	sdk/storage/azure-storage-blob-batch/pom.xml
#	sdk/storage/azure-storage-blob-changefeed/pom.xml
#	sdk/storage/azure-storage-blob-nio/pom.xml
#	sdk/storage/azure-storage-blob/pom.xml
#	sdk/storage/azure-storage-common/pom.xml
#	sdk/storage/azure-storage-file-datalake/pom.xml
#	sdk/storage/azure-storage-file-share/pom.xml
#	sdk/storage/azure-storage-internal-avro/pom.xml
#	sdk/storage/azure-storage-queue/pom.xml
#	sdk/tables/azure-data-tables/pom.xml
#	sdk/webpubsub/azure-messaging-webpubsub/pom.xml
  • Loading branch information
Netyyyy committed Nov 2, 2023
2 parents 3888218 + 1f21d93 commit c190ed4
Show file tree
Hide file tree
Showing 1,425 changed files with 33,935 additions and 14,908 deletions.
1 change: 1 addition & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@
"Onco",
"onenote",
"openai",
"passthrough",
"Pnative",
"premf",
"pwsh",
Expand Down
8 changes: 4 additions & 4 deletions common/perf-test-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.3.0</version> <!-- {x-version-update;org.apache.maven.plugins:maven-enforcer-plugin;external_dependency} -->
<version>3.0.0-M3</version> <!-- {x-version-update;org.apache.maven.plugins:maven-enforcer-plugin;external_dependency} -->
<configuration>
<rules>
<bannedDependencies>
<includes combine.children="append">
<include>com.fasterxml.jackson.core:jackson-databind:[2.15.3]</include> <!-- {x-include-update;com.fasterxml.jackson.core:jackson-databind;external_dependency} -->
<include>com.fasterxml.jackson.core:jackson-databind:[2.13.5]</include> <!-- {x-include-update;com.fasterxml.jackson.core:jackson-databind;external_dependency} -->

<!-- Special allowance for performance libraries as they aren't shipped. -->
<include>com.beust:jcommander:[1.78]</include> <!-- {x-include-update;com.beust:jcommander;external_dependency} -->

<include>io.projectreactor:reactor-core:[3.5.11]</include> <!-- {x-include-update;io.projectreactor:reactor-core;external_dependency} -->
<include>io.projectreactor:reactor-core:[3.4.33]</include> <!-- {x-include-update;io.projectreactor:reactor-core;external_dependency} -->
</includes>
</bannedDependencies>
</rules>
Expand All @@ -64,7 +64,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.15.3</version> <!-- {x-version-update;com.fasterxml.jackson.core:jackson-databind;external_dependency} -->
<version>2.13.5</version> <!-- {x-version-update;com.fasterxml.jackson.core:jackson-databind;external_dependency} -->
</dependency>
<dependency>
<groupId>com.beust</groupId>
Expand Down
6 changes: 3 additions & 3 deletions common/smoke-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version> <!-- {x-version-update;org.apache.maven.plugins:maven-compiler-plugin;external_dependency} -->
<version>3.10.1</version> <!-- {x-version-update;org.apache.maven.plugins:maven-compiler-plugin;external_dependency} -->
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand All @@ -62,7 +62,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version> <!-- {x-version-update;org.apache.maven.plugins:maven-compiler-plugin;external_dependency} -->
<version>3.10.1</version> <!-- {x-version-update;org.apache.maven.plugins:maven-compiler-plugin;external_dependency} -->
<configuration>
<source>${java.vm.specification.version}</source>
<target>${java.vm.specification.version}</target>
Expand Down Expand Up @@ -163,7 +163,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version> <!-- {x-version-update;org.apache.maven.plugins:maven-compiler-plugin;external_dependency} -->
<version>3.10.1</version> <!-- {x-version-update;org.apache.maven.plugins:maven-compiler-plugin;external_dependency} -->
</plugin>
</plugins>
</build>
Expand Down
2 changes: 2 additions & 0 deletions eng/.docsettings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ known_presence_issues:
- ['sdk/cognitiveservices/ms-azure-cs-visualsearch/CHANGELOG.md', '#2847']
- ['sdk/cognitiveservices/ms-azure-cs-websearch/CHANGELOG.md', '#2847']
- ['sdk/cosmos/azure-cosmos-examples/CHANGELOG.md', '#2847']
- ['sdk/cosmos/azure-cosmos-kafka-connect/CHANGELOG.md', '#2847']
- ['sdk/cosmos/CHANGELOG.md', '#2847']
- ['sdk/eventgrid/azure-messaging-eventgrid/CHANGELOG.md', '#2847']
- ['sdk/eventgrid/microsoft-azure-eventgrid/CHANGELOG.md', '#2847']
Expand Down Expand Up @@ -114,6 +115,7 @@ known_content_issues:
- ['sdk/cosmos/faq/README.md', '#3113']
- ['sdk/cosmos/azure-cosmos-benchmark/README.md', '#3113']
- ['sdk/cosmos/azure-cosmos-examples/README.md', '#3113']
- ['sdk/cosmos/azure-cosmos-kafka-connect/README.md', '#3113']
- ['sdk/cosmos/azure-cosmos/README.md', '#3113']
- ['sdk/cosmos/azure-cosmos-encryption/README.md', '#3113']
- ['sdk/cosmos/azure-cosmos-spark_3_2-12/README.md', '#3113']
Expand Down
2 changes: 1 addition & 1 deletion eng/bomgenerator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.15.3</version> <!-- {x-version-update;com.fasterxml.jackson.dataformat:jackson-dataformat-xml;external_dependency} -->
<version>2.13.5</version> <!-- {x-version-update;com.fasterxml.jackson.dataformat:jackson-dataformat-xml;external_dependency} -->
</dependency>
</dependencies>
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ private static ExternalApiStatus shouldExternalApiBeIgnored(TypeElement element)
|| "cosmos.".regionMatches(0, className, 10, 7)
|| "data.schemaregistry.".regionMatches(0, className, 10, 20)
|| "data.appconfiguration.".regionMatches(0, className, 10, 22)
|| "identity.".regionMatches(0, className, 10, 9)
|| "json.".regionMatches(0, className, 10, 5)
|| "messaging.eventgrid.".regionMatches(0, className, 10, 20)
|| "messaging.eventhubs.".regionMatches(0, className, 10, 20)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ the main ServiceBusClientBuilder. -->

<!-- Cosmos sdk suppressions -->
<suppress checks="[a-zA-Z0-9]*" files="[/\\]azure-cosmos-encryption[/\\]src[/\\]test[/\\]"/>
<suppress checks="[a-zA-Z0-9]*" files="[/\\]azure-cosmos-kafka-connect[/\\]src[/\\]test[/\\]"/>
<suppress checks="[a-zA-Z0-9]*"
files=".*[/\\]azure-cosmos[/\\]((?!(BridgeInternal|CosmosBridgeInternal|CommonsBridgeInternal)).*)"/>
<suppress checks="[a-zA-Z0-9]*"
Expand Down Expand Up @@ -568,7 +569,6 @@ the main ServiceBusClientBuilder. -->
<suppress checks="com.azure.tools.checkstyle.checks.GoodLoggingCheck" files="ConsoleLogger.java"/>
<suppress checks="com.azure.tools.checkstyle.checks.ThrowFromClientLoggerCheck"
files="com.azure.sdk.build.tool.*\.java"/>

<!-- Identity tests use paramaterization which requires a public field -->
<suppress checks="VisibilityModifier" files="com.azure.identity.AzureCliCredentialNegativeTest.java"/>
<suppress checks="VisibilityModifier" files="com.azure.identity.AzureDeveloperCliCredentialNegativeTest.java"/>
Expand Down
12 changes: 6 additions & 6 deletions eng/code-quality-reports/src/main/resources/revapi/revapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,6 @@
"new": "class com.azure.ai.formrecognizer.documentanalysis.models.(DocumentField|DocumentLine)",
"justification": "Skip customized getters on class when serialization and deserialization."
},
{
"regex": true,
"code": "java.annotation.added",
"new": "class com.azure.ai.textanalytics.models.HealthcareEntityRelationType",
"justification": "Skip JsonCreator annotation on the method fromString when serialization and deserialization."
},
{
"code": "java.class.removed",
"old": "enum com.azure.messaging.eventhubs.checkpointstore.blob.Messages",
Expand Down Expand Up @@ -312,6 +306,12 @@
"description": ".*com.fasterxml.jackson.*",
"justification": "Removing Jackson annotations from ACR, KeyVault, and Search in transition to stream-style."
},
{
"regex": true,
"code": "java\\.annotation\\.removed",
"old": ".*? com\\.azure\\.ai\\.textanalytics\\.models.*",
"justification": "Removing Jackson annotations from Text Analytics in transition to stream-style."
},
{
"code": "java.field.removed",
"old": "field com.azure.spring.cloud.core.properties.profile.AzureEnvironmentProperties.AZURE_GERMANY",
Expand Down
8 changes: 8 additions & 0 deletions eng/common/pipelines/templates/jobs/prepare-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ jobs:
name: azsdk-pool-mms-ubuntu-2204-general
vmImage: ubuntu-22.04
steps:
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
parameters:
Paths:
- 'sdk/**/*.yml'
- '!sdk/**/test-recordings/*'
- '!sdk/**/recordings/*'
- '!sdk/**/SessionRecords/*'
- '!sdk/**/session-records/*'
- template: /eng/common/pipelines/templates/steps/install-pipeline-generation.yml
- template: /eng/common/pipelines/templates/steps/set-default-branch.yml
# This covers our public repos.
Expand Down
169 changes: 81 additions & 88 deletions eng/common/scripts/Delete-RemoteBranches.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
[CmdletBinding(SupportsShouldProcess)]
param(
# Please use the RepoOwner/RepoName format: e.g. Azure/azure-sdk-for-java
$RepoId = "$RepoOwner/$RepoName",
# Upstream repo to check and see if there are existing open PRs from before deleting branch
$UpstreamRepoId,
$RepoId,
# CentralRepoId the original PR to generate sync PR. E.g Azure/azure-sdk-tools for eng/common
$CentralRepoId,
# We start from the sync PRs, use the branch name to get the PR number of central repo. E.g. sync-eng/common-(<branchName>)-(<PrNumber>). Have group name on PR number.
Expand All @@ -14,126 +12,121 @@ param(
[AllowNull()]
[DateTime]$LastCommitOlderThan,
[Switch]$DeleteBranchesEvenIfThereIsOpenPR = $false,
[Parameter(Mandatory = $true)]
$AuthToken
)
Set-StrictMode -version 3

. (Join-Path $PSScriptRoot common.ps1)

LogDebug "Operating on Repo [ $RepoId ]"
function Get-AllBranchesAndPullRequestInfo($owner, $repo) {
$query = @'
query($owner: String!, $repo: String!, $refPrefix: String!$endCursor: String) {
repository(owner: $owner, name: $repo) {
refs(first: 100, refPrefix: $refPrefix, after: $endCursor) {
nodes {
name
target {
commitUrl
... on Commit {
committedDate
}
}
associatedPullRequests(first: 100) {
nodes {
url
closed
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
'@

try{
# pull all branches.
$responses = Get-GitHubSourceReferences -RepoId $RepoId -Ref "heads" -AuthToken $AuthToken
$all_branches = gh api graphql --paginate -F owner=$owner -F repo=$repo -F refPrefix='refs/heads/' -f query=$query `
--jq '.data.repository.refs.nodes[] | { name, commitUrl: .target.commitUrl, committedDate: .target.committedDate, pullRequests: .associatedPullRequests.nodes }' | ConvertFrom-Json

if ($LASTEXITCODE) {
LogError "Failed to retrieve branches for '$owner' and '$repo' running query '$query'"
exit $LASTEXITCODE
}

return $all_branches
}
catch {
LogError "Get-GitHubSourceReferences failed with exception:`n$_"
exit 1

LogDebug "Operating on Repo '$RepoId'"

# Setup GH_TOKEN for the gh cli commands
if ($AuthToken) {
$env:GH_TOKEN = $AuthToken
}

foreach ($res in $responses)
$owner, $repo = $RepoId -split "/"
$branches = Get-AllBranchesAndPullRequestInfo $owner $repo

foreach ($branch in $branches)
{
if (!$res -or !$res.ref) {
LogDebug "No branch returned from the branch prefix $BranchRegex on $Repo. Skipping..."
continue
}
$branch = $res.ref
$branchName = $branch.Replace("refs/heads/","")
if (!($branchName -match $BranchRegex)) {
$branchName = $branch.Name
if ($branchName -notmatch $BranchRegex) {
continue
}
$openPullRequests = @($branch.pullRequests | Where-Object { !$_.Closed })

# If we have a central PR that created this branch still open still don't delete the branch
# If we have a central PR that created this branch still open don't delete the branch
if ($CentralRepoId)
{
$pullRequestNumber = $Matches["PrNumber"]
# If central PR number found, then skip
$pullRequestNumber = $matches["PrNumber"]
# If central PR number is not found, then skip
if (!$pullRequestNumber) {
LogError "No PR number found in the branch name. Please check the branch name [ $branchName ]. Skipping..."
LogError "No PR number found in the branch name. Please check the branch name '$branchName'. Skipping..."
continue
}

try {
$centralPR = Get-GitHubPullRequest -RepoId $CentralRepoId -PullRequestNumber $pullRequestNumber -AuthToken $AuthToken
LogDebug "Found central PR pull request: $($centralPR.html_url)"
if ($centralPR.state -ne "closed") {
# Skipping if there open central PR number for the branch.
continue
$centralPR = gh pr view --json 'url,closed' --repo $CentralRepoId $pullRequestNumber | ConvertFrom-Json
if ($LASTEXITCODE) {
LogError "PR '$pullRequestNumber' not found in repo '$CentralRepoId'. Skipping..."
continue;
} else {
LogDebug "Found central PR $($centralPR.url) and Closed=$($centralPR.closed)"
if (!$centralPR.Closed) {
# Skipping if there is an open central PR open for the branch.
LogDebug "Central PR is still open so skipping the deletion of branch '$branchName'. Skipping..."
continue;
}
}
catch
{
# If there is no central PR for the PR number, log error and skip.
LogError "Get-GitHubPullRequests failed with exception:`n$_"
LogError "Not found PR number [ $pullRequestNumber ] from [ $CentralRepoId ]. Skipping..."
continue
}
}

# If this branch has an open PR in the repo or the upstream repo then don't delete
try
{
$head = "${RepoId}:${branchName}"
LogDebug "Operating on branch [ $branchName ]"
$pullRequests = Get-GitHubPullRequests -RepoId $RepoId -State "all" -Head $head -AuthToken $AuthToken

# check to see if there are any PR's open in the main central repo as well.
if ($UpstreamRepoId) {
$pullRequests += Get-GitHubPullRequests -RepoId $UpstreamRepoId -State "all" -Head $head -AuthToken $AuthToken
else {
# Not CentralRepoId - not associated with a central repo PR
if ($openPullRequests.Count -gt 0 -and !$DeleteBranchesEvenIfThereIsOpenPR) {
LogDebug "Found open PRs associate with branch '$branchName'. Skipping..."
continue
}
}
catch
{
LogError "Get-GitHubPullRequests failed with exception:`n$_"
exit 1
}
$openPullRequests = @($pullRequests | Where-Object { $_.State -eq "open" })

if ($openPullRequests.Count -gt 0 -and !$DeleteBranchesEvenIfThereIsOpenPR) {
LogDebug "CentralRepoId is not configured and found open PRs associate with branch [ $branchName ]. Skipping..."
continue
}

# If there is date filter, then check if branch last commit older than the date.
# If there is date filter, then check if branch last commit is older than the date.
if ($LastCommitOlderThan)
{
if (!$res.object -or !$res.object.url) {
LogWarning "No commit url returned from response. Skipping... "
$commitDate = $branch.committedDate
if ($commitDate -gt $LastCommitOlderThan) {
LogDebug "The branch $branch last commit date '$commitDate' is newer than the date '$LastCommitOlderThan'. Skipping..."
continue
}
try {
$commitDate = Get-GithubReferenceCommitDate -commitUrl $res.object.url -AuthToken $AuthToken
if (!$commitDate) {
LogDebug "No last commit date found. Skipping."
continue
}
if ($commitDate -gt $LastCommitOlderThan) {
LogDebug "The branch $branch last commit date [ $commitDate ] is newer than the date $LastCommitOlderThan. Skipping."
continue
}

LogDebug "Branch [ $branchName ] in repo [ $RepoId ] has a last commit date [ $commitDate ] that is older than $LastCommitOlderThan. "
}
catch {
LogError "Get-GithubReferenceCommitDate failed with exception:`n$_"
exit 1
}
}

foreach ($openPullRequest in $openPullRequests) {
Write-Host "Open pull Request [ $($openPullRequest.html_url) ] will be closed after branch deletion."
Write-Host "Note: Open pull Request '$($openPullRequest.url)' will be closed after branch deletion, given the central PR is closed."
}

try
{
if ($PSCmdlet.ShouldProcess("[ $branchName ] in [ $RepoId ]", "Deleting branches on cleanup script")) {
Remove-GitHubSourceReferences -RepoId $RepoId -Ref $branch -AuthToken $AuthToken
Write-Host "The branch [ $branchName ] with sha [ $($res.object.sha) ] in [ $RepoId ] has been deleted."
$commitUrl = $branch.commitUrl
if ($PSCmdlet.ShouldProcess("'$branchName' in '$RepoId'", "Deleting branch on cleanup script")) {
gh api "repos/${RepoId}/git/refs/heads/${branchName}" -X DELETE
if ($LASTEXITCODE) {
LogError "Deletion of branch '$branchName` failed"
}
}
catch {
LogError "Remove-GitHubSourceReferences failed with exception:`n$_"
exit 1
Write-Host "The branch '$branchName' at commit '$commitUrl' in '$RepoId' has been deleted."
}
}
Loading

0 comments on commit c190ed4

Please sign in to comment.