Skip to content

Commit 68c3ed9

Browse files
authored
Checkout target deployment destination (#116)
* Checkout target deployment destination * Init git repository with intended branch * Create branch if it doesn't exist * Add test master branch switch
1 parent 9e1b20a commit 68c3ed9

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Sources/Publish/API/DeploymentMethod.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ public extension DeploymentMethod {
5959
at: folder.path
6060
)
6161

62+
try shellOut(
63+
to: "git checkout \(branch) || git checkout -b \(branch)",
64+
at: folder.path
65+
)
66+
6267
try folder.empty()
6368
}
6469

Tests/PublishTests/Tests/DeploymentTests.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ final class DeploymentTests: PublishTestCase {
6262

6363
try shellOut(to: [
6464
"git init",
65+
// Not all git installations init with a master branch.
66+
"git checkout master || git checkout -b master",
6567
"git config --local receive.denyCurrentBranch updateInstead"
6668
], at: remote.path)
6769

@@ -86,7 +88,14 @@ final class DeploymentTests: PublishTestCase {
8688
let remote = try container.createSubfolder(named: "Remote.git")
8789
let repo = try container.createSubfolder(named: "Repo")
8890

89-
try shellOut(to: .gitInit(), at: remote.path)
91+
try shellOut(
92+
to: [
93+
"git init",
94+
// Not all git installations init with a master branch.
95+
"git checkout master || git checkout -b master"
96+
],
97+
at: remote.path
98+
)
9099

91100
// First generate
92101
try publishWebsite(in: repo, using: [

0 commit comments

Comments
 (0)