Skip to content

Commit

Permalink
fallback if fetch_head doesn't have branch (#128)
Browse files Browse the repository at this point in the history
pass GH variables to tests
  • Loading branch information
ypopovych authored Aug 22, 2024
1 parent 7ee1c88 commit 6a0dd8c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
12 changes: 12 additions & 0 deletions IntegrationTests/UITests/IntegrationTestsUITests.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@
"key" : "GITHUB_REPOSITORY",
"value" : "$(GITHUB_REPOSITORY)"
},
{
"key" : "GITHUB_REF",
"value" : "$(GITHUB_REF)"
},
{
"key" : "GITHUB_HEAD_REF",
"value" : "$(GITHUB_HEAD_REF)"
},
{
"key" : "GITHUB_ACTIONS",
"value" : "$(GITHUB_ACTIONS)"
},
{
"key" : "DD_ENV",
"value" : "internal-tests"
Expand Down
11 changes: 8 additions & 3 deletions Sources/DatadogSDKTesting/Utils/GitInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@ struct GitInfo {
commit = refData.trimmingCharacters(in: .whitespacesAndNewlines)
} else {
let fetchHeadPath = gitFolder.appendingPathComponent("FETCH_HEAD")
if let records = FetchHeadRecord.from(file: fetchHeadPath)?
.filter({$0.commit == head && $0.type == "branch"}), records.count > 0 {
self.branch = records.first!.ref
if let records = FetchHeadRecord.from(file: fetchHeadPath)?.filter({$0.commit == head}),
records.count > 0
{
if let branchRef = records.first(where: { $0.type == "branch" }) {
self.branch = branchRef.ref
} else { // Seems as we have only a tag ref
self.branch = records.first!.ref
}
}
commit = head
}
Expand Down

0 comments on commit 6a0dd8c

Please sign in to comment.