deploy-vir 0.2.0 → 0.2.2

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.
Files changed (3) hide show
  1. package/dist/git.js +14 -12
  2. package/package.json +1 -1
  3. package/src/git.ts +20 -15
package/dist/git.js CHANGED
@@ -48,10 +48,9 @@ export async function pushDeploy(git, { deployName, fromBranch, toBranch }, remo
48
48
  '-1',
49
49
  ])).latest, `Failed to get current commit for ${remoteName}/${fromBranch}`);
50
50
  /** Get commits that are on {@link toBranch} but not on {@link fromBranch}. */
51
- const commitsAhead = (await git.log({
52
- from: `${remoteName}/${toBranch}`,
53
- to: `${remoteName}/${fromBranch}`,
54
- })).all;
51
+ const commitsAhead = (await git.log([
52
+ `${remoteName}/${toBranch}..${remoteName}/${fromBranch}`,
53
+ ])).all;
55
54
  if (!commitsAhead.length) {
56
55
  throw new KnownError('No commit diff: nothing to deploy!');
57
56
  }
@@ -71,13 +70,16 @@ export async function pushDeploy(git, { deployName, fromBranch, toBranch }, remo
71
70
  catch (error) {
72
71
  log.error(`Push failed: ${extractErrorMessage(error)}`);
73
72
  /** Get commits that are on {@link toBranch} but not on {@link fromBranch}. */
74
- const commitsBehind = await git.log({
75
- from: `${remoteName}/${fromBranch}`,
76
- to: `${remoteName}/${toBranch}`,
77
- });
78
- if (commitsBehind.total > 0) {
79
- log.info(`\nThe following ${commitsBehind.total} commit${commitsBehind.total === 1 ? '' : 's'} are on ${logColors.bold}${toBranch}${logColors.reset} but not on ${logColors.bold}${fromBranch}${logColors.reset}:`);
80
- commitsBehind.all.forEach((commit, index) => {
73
+ const commitsBehind = (await git.log([
74
+ `${remoteName}/${fromBranch}..${remoteName}/${toBranch}`,
75
+ ])).all;
76
+ if (commitsBehind.length > 0) {
77
+ log.info(`\nOnn ${logColors.bold}${fromBranch}${logColors.reset}:`);
78
+ commitsBehind.forEach((commit, index) => {
79
+ log.faint(` ${index + 1}. ${commit.hash.slice(0, 7)} (${commit.author_name}) - ${commit.message}`);
80
+ });
81
+ log.info(`\nOnn ${logColors.bold}${toBranch}${logColors.reset}:`);
82
+ commitsBehind.forEach((commit, index) => {
81
83
  log.faint(` ${index + 1}. ${commit.hash.slice(0, 7)} (${commit.author_name}) - ${commit.message}`);
82
84
  });
83
85
  }
@@ -92,7 +94,7 @@ export async function pushDeploy(git, { deployName, fromBranch, toBranch }, remo
92
94
  return {
93
95
  deployCommits: {
94
96
  deployedCommits: commitsAhead,
95
- overwrittenCommits: commitsBehind.all,
97
+ overwrittenCommits: commitsBehind,
96
98
  },
97
99
  branchStatus: {
98
100
  before: beforeCommit,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deploy-vir",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Deploy a branch to another branch with notifications.",
5
5
  "keywords": [
6
6
  "deploy",
package/src/git.ts CHANGED
@@ -125,10 +125,9 @@ export async function pushDeploy(
125
125
 
126
126
  /** Get commits that are on {@link toBranch} but not on {@link fromBranch}. */
127
127
  const commitsAhead = (
128
- await git.log({
129
- from: `${remoteName}/${toBranch}`,
130
- to: `${remoteName}/${fromBranch}`,
131
- })
128
+ await git.log([
129
+ `${remoteName}/${toBranch}..${remoteName}/${fromBranch}`,
130
+ ])
132
131
  ).all;
133
132
 
134
133
  if (!commitsAhead.length) {
@@ -152,16 +151,22 @@ export async function pushDeploy(
152
151
  log.error(`Push failed: ${extractErrorMessage(error)}`);
153
152
 
154
153
  /** Get commits that are on {@link toBranch} but not on {@link fromBranch}. */
155
- const commitsBehind = await git.log({
156
- from: `${remoteName}/${fromBranch}`,
157
- to: `${remoteName}/${toBranch}`,
158
- });
159
-
160
- if (commitsBehind.total > 0) {
161
- log.info(
162
- `\nThe following ${commitsBehind.total} commit${commitsBehind.total === 1 ? '' : 's'} are on ${logColors.bold}${toBranch}${logColors.reset} but not on ${logColors.bold}${fromBranch}${logColors.reset}:`,
163
- );
164
- commitsBehind.all.forEach((commit, index) => {
154
+ const commitsBehind = (
155
+ await git.log([
156
+ `${remoteName}/${fromBranch}..${remoteName}/${toBranch}`,
157
+ ])
158
+ ).all;
159
+
160
+ if (commitsBehind.length > 0) {
161
+ log.info(`\nOnn ${logColors.bold}${fromBranch}${logColors.reset}:`);
162
+ commitsBehind.forEach((commit, index) => {
163
+ log.faint(
164
+ ` ${index + 1}. ${commit.hash.slice(0, 7)} (${commit.author_name}) - ${commit.message}`,
165
+ );
166
+ });
167
+
168
+ log.info(`\nOnn ${logColors.bold}${toBranch}${logColors.reset}:`);
169
+ commitsBehind.forEach((commit, index) => {
165
170
  log.faint(
166
171
  ` ${index + 1}. ${commit.hash.slice(0, 7)} (${commit.author_name}) - ${commit.message}`,
167
172
  );
@@ -184,7 +189,7 @@ export async function pushDeploy(
184
189
  return {
185
190
  deployCommits: {
186
191
  deployedCommits: commitsAhead,
187
- overwrittenCommits: commitsBehind.all,
192
+ overwrittenCommits: commitsBehind,
188
193
  },
189
194
  branchStatus: {
190
195
  before: beforeCommit,