Skip to content
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

fix: Release note exit codes cause script failure, other release note issues #1050

Merged
merged 1 commit into from
Jun 23, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ struct PrepareRelease {
let releaseNotes = ReleaseNotesBuilder(
previousVersion: previousVersion,
newVersion: newVersion,
repoType: repoType,
commits: commits
).build()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import PackageDescription
struct ReleaseNotesBuilder {
let previousVersion: Version
let newVersion: Version
let repoType: PrepareRelease.Repo
let commits: [String]

// MARK: - Build
Expand All @@ -21,7 +22,7 @@ struct ReleaseNotesBuilder {
"## What's Changed",
buildCommits(),
.newline,
"**Full Changelog**: https://github.com/awslabs/aws-sdk-swift/compare/\(previousVersion)...\(newVersion)"
"**Full Changelog**: https://github.com/awslabs/\(repoType.rawValue)/compare/\(previousVersion)...\(newVersion)"
]
return contents.joined(separator: .newline)
}
Expand Down
23 changes: 16 additions & 7 deletions AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Utils/Process+Git.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import Foundation
import PackageDescription
import struct ArgumentParser.ExitCode

extension Process {
/// A struct to create processes for executing git commands.
Expand Down Expand Up @@ -61,7 +62,7 @@ extension Process {
/// Returns a process for executing `git log <a>..<b> --pretty=format:<format>`
/// This is used returning the list of commits between two tags.
func log(_ a: String, _ b: String, format: String) -> Process {
gitProcess(["log", "\(a)...\(b)", "--pretty=format:\(format.wrappedInQuotes())"])
gitProcess(["log", "\(a)...\(b)", "--pretty=format:\(format)"])
}
}

Expand All @@ -72,18 +73,26 @@ extension Process.Git {
/// Returns true if the provided commits/branches/trees are different, otherwise returns false
func diffHasChanges(_ a: String, _ b: String) throws -> Bool {
let task = diff(a, b)
try _run(task)
return task.terminationStatus != 0
do {
try _run(task)
} catch let exitCode as ExitCode where exitCode.rawValue == 1 {
return true
}
return false
}

/// Returns true if the local working copy has unstaged or uncommitted changes, otherwise returns false.
func hasLocalChanges() throws -> Bool {
let updateIndexTask = updateIndex()
try _run(updateIndexTask)
try? _run(updateIndexTask)

let diffIndexTask = diffIndex()
try _run(diffIndexTask)
return diffIndexTask.terminationStatus != 0
do {
let diffIndexTask = diffIndex()
try _run(diffIndexTask)
} catch let exitCode as ExitCode where exitCode.rawValue == 1 {
return true
}
return false
}

func listOfCommitsBetween(_ a: String, _ b: String) throws -> [String] {
Expand Down