git-watchtower 1.9.0 → 1.9.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 +1 -1
- package/src/git/branch.js +13 -6
package/package.json
CHANGED
package/src/git/branch.js
CHANGED
|
@@ -98,14 +98,17 @@ async function getAllBranches(options = {}) {
|
|
|
98
98
|
const seenBranches = new Set();
|
|
99
99
|
|
|
100
100
|
// Get local branches
|
|
101
|
+
// Use \x1f (Unit Separator) as delimiter since | can appear in commit subjects
|
|
102
|
+
const delimiter = '\x1f';
|
|
101
103
|
const localResult = await execGitSilent(
|
|
102
|
-
['for-each-ref', '--sort=-committerdate',
|
|
104
|
+
['for-each-ref', '--sort=-committerdate', `--format=%(refname:short)${delimiter}%(committerdate:iso8601)${delimiter}%(objectname:short)${delimiter}%(subject)`, 'refs/heads/'],
|
|
103
105
|
{ cwd }
|
|
104
106
|
);
|
|
105
107
|
|
|
106
108
|
if (localResult) {
|
|
107
109
|
for (const line of localResult.stdout.split('\n').filter(Boolean)) {
|
|
108
|
-
const [name, dateStr, commit,
|
|
110
|
+
const [name, dateStr, commit, ...subjectParts] = line.split(delimiter);
|
|
111
|
+
const subject = subjectParts.join(delimiter);
|
|
109
112
|
if (!seenBranches.has(name) && isValidBranchName(name)) {
|
|
110
113
|
seenBranches.add(name);
|
|
111
114
|
branchList.push({
|
|
@@ -123,14 +126,15 @@ async function getAllBranches(options = {}) {
|
|
|
123
126
|
|
|
124
127
|
// Get remote branches
|
|
125
128
|
const remoteResult = await execGitSilent(
|
|
126
|
-
['for-each-ref', '--sort=-committerdate',
|
|
129
|
+
['for-each-ref', '--sort=-committerdate', `--format=%(refname:short)${delimiter}%(committerdate:iso8601)${delimiter}%(objectname:short)${delimiter}%(subject)`, `refs/remotes/${remoteName}/`],
|
|
127
130
|
{ cwd }
|
|
128
131
|
);
|
|
129
132
|
|
|
130
133
|
if (remoteResult) {
|
|
131
134
|
const remotePrefix = `${remoteName}/`;
|
|
132
135
|
for (const line of remoteResult.stdout.split('\n').filter(Boolean)) {
|
|
133
|
-
const [fullName, dateStr, commit,
|
|
136
|
+
const [fullName, dateStr, commit, ...subjectParts] = line.split(delimiter);
|
|
137
|
+
const subject = subjectParts.join(delimiter);
|
|
134
138
|
const name = fullName.replace(remotePrefix, '');
|
|
135
139
|
|
|
136
140
|
if (name === 'HEAD') continue;
|
|
@@ -265,9 +269,10 @@ async function getPreviewData(branchName, options = {}) {
|
|
|
265
269
|
const safeName = sanitizeBranchName(branchName);
|
|
266
270
|
|
|
267
271
|
// Get recent commits
|
|
272
|
+
// Use %x1f (Unit Separator) as delimiter since | can appear in commit subjects
|
|
268
273
|
const commitLog = await log(safeName, {
|
|
269
274
|
count: commitCount,
|
|
270
|
-
format: '%h
|
|
275
|
+
format: '%h%x1f%s%x1f%cr',
|
|
271
276
|
cwd,
|
|
272
277
|
});
|
|
273
278
|
|
|
@@ -275,7 +280,9 @@ async function getPreviewData(branchName, options = {}) {
|
|
|
275
280
|
.split('\n')
|
|
276
281
|
.filter(Boolean)
|
|
277
282
|
.map((line) => {
|
|
278
|
-
const [hash,
|
|
283
|
+
const [hash, ...rest] = line.split('\x1f');
|
|
284
|
+
const time = rest.pop() || '';
|
|
285
|
+
const subject = rest.join('\x1f');
|
|
279
286
|
return { hash, subject, time };
|
|
280
287
|
});
|
|
281
288
|
|