@afoures/auto-release 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -75,24 +75,27 @@ function github(options) {
|
|
|
75
75
|
parents: [base_sha]
|
|
76
76
|
})
|
|
77
77
|
});
|
|
78
|
+
let branch_exists = false;
|
|
78
79
|
try {
|
|
79
|
-
await api_request(`/git/
|
|
80
|
-
|
|
81
|
-
body: JSON.stringify({
|
|
82
|
-
sha: commit.sha,
|
|
83
|
-
force: false
|
|
84
|
-
})
|
|
85
|
-
});
|
|
80
|
+
await api_request(`/git/ref/heads/${branch_name}`);
|
|
81
|
+
branch_exists = true;
|
|
86
82
|
} catch (error) {
|
|
87
|
-
if (error.message.includes("404"))
|
|
88
|
-
method: "POST",
|
|
89
|
-
body: JSON.stringify({
|
|
90
|
-
ref: `refs/heads/${branch_name}`,
|
|
91
|
-
sha: commit.sha
|
|
92
|
-
})
|
|
93
|
-
});
|
|
94
|
-
else throw error;
|
|
83
|
+
if (!error.message.includes("404")) throw error;
|
|
95
84
|
}
|
|
85
|
+
if (branch_exists) await api_request(`/git/refs/heads/${branch_name}`, {
|
|
86
|
+
method: "PATCH",
|
|
87
|
+
body: JSON.stringify({
|
|
88
|
+
sha: commit.sha,
|
|
89
|
+
force: true
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
else await api_request("/git/refs", {
|
|
93
|
+
method: "POST",
|
|
94
|
+
body: JSON.stringify({
|
|
95
|
+
ref: `refs/heads/${branch_name}`,
|
|
96
|
+
sha: commit.sha
|
|
97
|
+
})
|
|
98
|
+
});
|
|
96
99
|
return commit.sha;
|
|
97
100
|
},
|
|
98
101
|
async create_or_update_pull_request(args) {
|
package/dist/lib/utils/git.mjs
CHANGED
|
@@ -12,7 +12,7 @@ async function diff(cwd) {
|
|
|
12
12
|
const { stdout: status_output } = await exec("git status --porcelain", cwd ? { cwd } : void 0);
|
|
13
13
|
if (!status_output.trim()) return [];
|
|
14
14
|
const operations = [];
|
|
15
|
-
const lines = status_output.
|
|
15
|
+
const lines = status_output.split("\n");
|
|
16
16
|
for (const line of lines) {
|
|
17
17
|
if (!line.trim()) continue;
|
|
18
18
|
const status = line.substring(0, 2);
|