git-stack-cli 2.8.0 → 2.8.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-stack-cli",
3
- "version": "2.8.0",
3
+ "version": "2.8.1",
4
4
  "description": "",
5
5
  "author": "magus",
6
6
  "license": "MIT",
@@ -6,6 +6,9 @@ import { spawn } from "~/core/spawn";
6
6
 
7
7
  process.env.NODE_ENV = "production";
8
8
 
9
+ // ensure npm is authenticated
10
+ await spawn(`npm whoami`);
11
+
9
12
  // get paths relative to this script
10
13
  const REPO_ROOT = (await spawn.sync("git rev-parse --show-toplevel")).stdout;
11
14
  const DIST_DIR = path.join(REPO_ROOT, "dist");
@@ -54,9 +57,6 @@ for (const filepath of package_json.files) {
54
57
  }
55
58
  }
56
59
 
57
- // ensure npm is authenticated
58
- await spawn(`npm whoami`);
59
-
60
60
  process.chdir(REPO_ROOT);
61
61
 
62
62
  await spawn.sync(`git commit -a -m ${version}`);
@@ -75,12 +75,15 @@ async function run() {
75
75
 
76
76
  const git_push_target_list: Array<string> = [];
77
77
 
78
- for (const group of push_group_list) {
78
+ for (let i = 0; i < push_group_list.length; i++) {
79
+ const group = push_group_list[i];
79
80
  const last_commit = last(group.commits);
80
81
  invariant(last_commit, "last_commit must exist");
81
82
 
82
83
  // push group in isolation if master_base is set
83
- if (group.master_base) {
84
+ // for the first group (i > 0) we can skip this
85
+ // since it'll be based off master anyway
86
+ if (group.master_base && i > 0) {
84
87
  await push_master_group(group);
85
88
  continue;
86
89
  }
@@ -121,6 +121,7 @@ export async function range(commit_group_map?: CommitGroupMap) {
121
121
 
122
122
  for (let i = 0; i < group_value_list.length; i++) {
123
123
  const group = group_value_list[i];
124
+ const previous_group: undefined | CommitGroup = group_value_list[i - 1];
124
125
 
125
126
  if (group.id !== UNASSIGNED) {
126
127
  let pr_result = pr_lookup[group.id];
@@ -164,29 +165,61 @@ export async function range(commit_group_map?: CommitGroupMap) {
164
165
 
165
166
  if (!group.pr) {
166
167
  group.dirty = true;
167
- } else if (group.pr.commits.length !== group.commits.length) {
168
- group.dirty = true;
169
- } else if (group.pr.baseRefName !== group.base) {
170
- group.dirty = true;
171
- } else if (group.master_base) {
172
- group.pr.number;
173
- // master_base groups cannot be compared by commit sha
174
- // instead compare the literal diff local against origin
175
- // gh pr diff --color=never 110
176
- // git --no-pager diff --color=never 00c8fe0~1..00c8fe0 | pbcopy
177
- const diff_github = await github.pr_diff(group.pr.number);
178
- const diff_local = await git.get_diff(group.commits);
179
- if (diff_github !== diff_local) {
180
- group.dirty = true;
181
- }
182
168
  } else {
183
- // comapre literal commit shas in group
184
- for (let i = 0; i < group.pr.commits.length; i++) {
185
- const pr_commit = group.pr.commits[i];
186
- const local_commit = group.commits[i];
169
+ if (group.pr.baseRefName !== group.base) {
170
+ group.dirty = true;
171
+ } else if (group.master_base && i > 0) {
172
+ // special case
173
+ // master_base groups cannot be compared by commit sha
174
+ // instead compare the literal diff local against origin
175
+ // gh pr diff --color=never 110
176
+ // git --no-pager diff --color=never 00c8fe0~1..00c8fe0
177
+ const diff_github = await github.pr_diff(group.pr.number);
178
+ const diff_local = await git.get_diff(group.commits);
179
+ if (diff_github !== diff_local) {
180
+ group.dirty = true;
181
+ }
182
+ } else if (!group.master_base && previous_group && previous_group.master_base) {
183
+ // special case
184
+ // boundary between normal commits and master commits
185
+
186
+ // collect all previous groups for sha comparison
187
+ const all_commits: Array<git.Commit> = [];
188
+ const previous_groups = group_value_list.slice(0, i);
189
+ for (const g of previous_groups) {
190
+ for (const c of g.commits) {
191
+ all_commits.push(c);
192
+ }
193
+ }
194
+ for (const c of group.commits) {
195
+ all_commits.push(c);
196
+ }
187
197
 
188
- if (pr_commit.oid !== local_commit.sha) {
198
+ // compare all commits against pr commits
199
+ if (group.pr.commits.length !== all_commits.length) {
189
200
  group.dirty = true;
201
+ } else {
202
+ for (let i = 0; i < group.pr.commits.length; i++) {
203
+ const pr_commit = group.pr.commits[i];
204
+ const local_commit = all_commits[i];
205
+
206
+ if (pr_commit.oid !== local_commit.sha) {
207
+ group.dirty = true;
208
+ }
209
+ }
210
+ }
211
+ } else if (group.pr.commits.length !== group.commits.length) {
212
+ group.dirty = true;
213
+ } else {
214
+ // if we still haven't marked this dirty, check each commit
215
+ // comapre literal commit shas in group
216
+ for (let i = 0; i < group.pr.commits.length; i++) {
217
+ const pr_commit = group.pr.commits[i];
218
+ const local_commit = group.commits[i];
219
+
220
+ if (pr_commit.oid !== local_commit.sha) {
221
+ group.dirty = true;
222
+ }
190
223
  }
191
224
  }
192
225
  }