@afoures/auto-release 0.2.7 → 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/refs/heads/${branch_name}`, {
80
- method: "PATCH",
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")) await api_request("/git/refs", {
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) {
@@ -65,8 +65,8 @@ ${error_text}`);
65
65
  branch: branch_name,
66
66
  commit_message,
67
67
  actions,
68
- start_branch: branch_exists ? branch_name : void 0,
69
- start_sha: branch_exists ? void 0 : base_sha
68
+ start_sha: base_sha,
69
+ force: branch_exists
70
70
  })
71
71
  })).id;
72
72
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afoures/auto-release",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "A file based release management tool for monorepos",
5
5
  "homepage": "https://github.com/afoures/auto-release#readme",
6
6
  "bugs": {