@pilatos/bitbucket-cli 1.2.0 → 1.3.0
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/README.md +12 -1
- package/dist/index.js +272 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -83,7 +83,7 @@ bb pr list
|
|
|
83
83
|
|----------|----------|
|
|
84
84
|
| **Authentication** | `login`, `logout`, `status`, `token` |
|
|
85
85
|
| **Repositories** | `clone`, `create`, `list`, `view`, `delete` |
|
|
86
|
-
| **Pull Requests** | `create`, `list`, `view`, `edit`, `merge`, `approve`, `decline`, `checkout`, `diff`, `comment`, `comments` |
|
|
86
|
+
| **Pull Requests** | `create`, `list`, `view`, `edit`, `merge`, `approve`, `decline`, `ready`, `checkout`, `diff`, `comment`, `comments` |
|
|
87
87
|
| **Configuration** | `get`, `set`, `list` |
|
|
88
88
|
| **Shell Completion** | `install`, `uninstall` |
|
|
89
89
|
|
|
@@ -138,10 +138,21 @@ bb pr list
|
|
|
138
138
|
|
|
139
139
|
# Review and merge
|
|
140
140
|
bb pr view 42
|
|
141
|
+
bb pr activity 42
|
|
141
142
|
bb pr approve 42
|
|
142
143
|
bb pr merge 42
|
|
143
144
|
```
|
|
144
145
|
|
|
146
|
+
### Draft Pull Requests
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# Create a draft PR for early feedback
|
|
150
|
+
bb pr create --title "WIP: Add new feature" --draft
|
|
151
|
+
|
|
152
|
+
# Mark it ready for review when done
|
|
153
|
+
bb pr ready 123
|
|
154
|
+
```
|
|
155
|
+
|
|
145
156
|
### Scripting with JSON
|
|
146
157
|
|
|
147
158
|
```bash
|
package/dist/index.js
CHANGED
|
@@ -4302,7 +4302,7 @@ var require_lodash = __commonJS((exports, module) => {
|
|
|
4302
4302
|
function unicodeWords(string) {
|
|
4303
4303
|
return string.match(reUnicodeWord) || [];
|
|
4304
4304
|
}
|
|
4305
|
-
var runInContext = function
|
|
4305
|
+
var runInContext = function runInContext2(context) {
|
|
4306
4306
|
context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
|
|
4307
4307
|
var { Array: Array2, Date: Date2, Error: Error2, Function: Function2, Math: Math2, Object: Object2, RegExp: RegExp2, String: String2, TypeError: TypeError2 } = context;
|
|
4308
4308
|
var arrayProto = Array2.prototype, funcProto = Function2.prototype, objectProto = Object2.prototype;
|
|
@@ -8815,7 +8815,7 @@ __p += '`;
|
|
|
8815
8815
|
lodash.replace = replace;
|
|
8816
8816
|
lodash.result = result;
|
|
8817
8817
|
lodash.round = round;
|
|
8818
|
-
lodash.runInContext =
|
|
8818
|
+
lodash.runInContext = runInContext2;
|
|
8819
8819
|
lodash.sample = sample2;
|
|
8820
8820
|
lodash.size = size;
|
|
8821
8821
|
lodash.snakeCase = snakeCase;
|
|
@@ -17469,7 +17469,7 @@ var require_multicast = __commonJS((exports) => {
|
|
|
17469
17469
|
if (typeof subjectOrSubjectFactory === "function") {
|
|
17470
17470
|
subjectFactory = subjectOrSubjectFactory;
|
|
17471
17471
|
} else {
|
|
17472
|
-
subjectFactory = function
|
|
17472
|
+
subjectFactory = function subjectFactory2() {
|
|
17473
17473
|
return subjectOrSubjectFactory;
|
|
17474
17474
|
};
|
|
17475
17475
|
}
|
|
@@ -20940,7 +20940,7 @@ var require_signal_exit = __commonJS((exports, module) => {
|
|
|
20940
20940
|
emitter.on(ev, cb);
|
|
20941
20941
|
return remove;
|
|
20942
20942
|
};
|
|
20943
|
-
unload = function
|
|
20943
|
+
unload = function unload2() {
|
|
20944
20944
|
if (!loaded || !processOk(global.process)) {
|
|
20945
20945
|
return;
|
|
20946
20946
|
}
|
|
@@ -20955,7 +20955,7 @@ var require_signal_exit = __commonJS((exports, module) => {
|
|
|
20955
20955
|
emitter.count -= 1;
|
|
20956
20956
|
};
|
|
20957
20957
|
module.exports.unload = unload;
|
|
20958
|
-
emit = function
|
|
20958
|
+
emit = function emit2(event, code, signal) {
|
|
20959
20959
|
if (emitter.emitted[event]) {
|
|
20960
20960
|
return;
|
|
20961
20961
|
}
|
|
@@ -20984,7 +20984,7 @@ var require_signal_exit = __commonJS((exports, module) => {
|
|
|
20984
20984
|
return signals;
|
|
20985
20985
|
};
|
|
20986
20986
|
loaded = false;
|
|
20987
|
-
load = function
|
|
20987
|
+
load = function load2() {
|
|
20988
20988
|
if (loaded || !processOk(global.process)) {
|
|
20989
20989
|
return;
|
|
20990
20990
|
}
|
|
@@ -21003,7 +21003,7 @@ var require_signal_exit = __commonJS((exports, module) => {
|
|
|
21003
21003
|
};
|
|
21004
21004
|
module.exports.load = load;
|
|
21005
21005
|
originalProcessReallyExit = process3.reallyExit;
|
|
21006
|
-
processReallyExit = function
|
|
21006
|
+
processReallyExit = function processReallyExit2(code) {
|
|
21007
21007
|
if (!processOk(global.process)) {
|
|
21008
21008
|
return;
|
|
21009
21009
|
}
|
|
@@ -21013,7 +21013,7 @@ var require_signal_exit = __commonJS((exports, module) => {
|
|
|
21013
21013
|
originalProcessReallyExit.call(process3, process3.exitCode);
|
|
21014
21014
|
};
|
|
21015
21015
|
originalProcessEmit = process3.emit;
|
|
21016
|
-
processEmit = function
|
|
21016
|
+
processEmit = function processEmit2(ev, arg) {
|
|
21017
21017
|
if (ev === "exit" && processOk(global.process)) {
|
|
21018
21018
|
if (arg !== undefined) {
|
|
21019
21019
|
process3.exitCode = arg;
|
|
@@ -33262,8 +33262,10 @@ var ServiceTokens = {
|
|
|
33262
33262
|
MergePRCommand: "MergePRCommand",
|
|
33263
33263
|
ApprovePRCommand: "ApprovePRCommand",
|
|
33264
33264
|
DeclinePRCommand: "DeclinePRCommand",
|
|
33265
|
+
ReadyPRCommand: "ReadyPRCommand",
|
|
33265
33266
|
CheckoutPRCommand: "CheckoutPRCommand",
|
|
33266
33267
|
DiffPRCommand: "DiffPRCommand",
|
|
33268
|
+
ActivityPRCommand: "ActivityPRCommand",
|
|
33267
33269
|
CommentPRCommand: "CommentPRCommand",
|
|
33268
33270
|
ListCommentsPRCommand: "ListCommentsPRCommand",
|
|
33269
33271
|
EditCommentPRCommand: "EditCommentPRCommand",
|
|
@@ -34249,10 +34251,22 @@ class HttpClient {
|
|
|
34249
34251
|
configService;
|
|
34250
34252
|
baseUrl;
|
|
34251
34253
|
timeout;
|
|
34254
|
+
debug;
|
|
34252
34255
|
constructor(configService, config) {
|
|
34253
34256
|
this.configService = configService;
|
|
34254
34257
|
this.baseUrl = config?.baseUrl ?? "https://api.bitbucket.org/2.0";
|
|
34255
34258
|
this.timeout = config?.timeout ?? 30000;
|
|
34259
|
+
this.debug = config?.debug ?? process.env.DEBUG === "true";
|
|
34260
|
+
}
|
|
34261
|
+
logDebug(message, data) {
|
|
34262
|
+
if (!this.debug) {
|
|
34263
|
+
return;
|
|
34264
|
+
}
|
|
34265
|
+
if (data === undefined) {
|
|
34266
|
+
console.log(`[debug] ${message}`);
|
|
34267
|
+
return;
|
|
34268
|
+
}
|
|
34269
|
+
console.log(`[debug] ${message}`, data);
|
|
34256
34270
|
}
|
|
34257
34271
|
async getAuthHeader() {
|
|
34258
34272
|
const credentialsResult = await this.configService.getCredentials();
|
|
@@ -34274,13 +34288,20 @@ class HttpClient {
|
|
|
34274
34288
|
Accept: acceptText ? "text/plain" : "application/json"
|
|
34275
34289
|
};
|
|
34276
34290
|
const url = `${this.baseUrl}${path}`;
|
|
34291
|
+
const requestBody = body ? JSON.stringify(body) : undefined;
|
|
34277
34292
|
try {
|
|
34278
34293
|
const controller = new AbortController;
|
|
34279
34294
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
34295
|
+
this.logDebug("Request", {
|
|
34296
|
+
url,
|
|
34297
|
+
method,
|
|
34298
|
+
headers,
|
|
34299
|
+
body: requestBody
|
|
34300
|
+
});
|
|
34280
34301
|
const response = await fetch(url, {
|
|
34281
34302
|
method,
|
|
34282
34303
|
headers,
|
|
34283
|
-
body:
|
|
34304
|
+
body: requestBody,
|
|
34284
34305
|
signal: controller.signal
|
|
34285
34306
|
});
|
|
34286
34307
|
if (process.env.DEBUG === "true") {
|
|
@@ -34289,8 +34310,25 @@ class HttpClient {
|
|
|
34289
34310
|
console.debug(`[HTTP] Response Body:`, await response.clone().text());
|
|
34290
34311
|
}
|
|
34291
34312
|
clearTimeout(timeoutId);
|
|
34313
|
+
if (this.debug) {
|
|
34314
|
+
const responseClone = response.clone();
|
|
34315
|
+
const responseText = await responseClone.text();
|
|
34316
|
+
this.logDebug("Response", {
|
|
34317
|
+
url,
|
|
34318
|
+
method,
|
|
34319
|
+
status: response.status,
|
|
34320
|
+
statusText: response.statusText,
|
|
34321
|
+
headers: Object.fromEntries(response.headers.entries()),
|
|
34322
|
+
body: responseText
|
|
34323
|
+
});
|
|
34324
|
+
}
|
|
34292
34325
|
return acceptText ? this.handleTextResponse(response) : this.handleResponse(response);
|
|
34293
34326
|
} catch (error) {
|
|
34327
|
+
this.logDebug("Request error", {
|
|
34328
|
+
url,
|
|
34329
|
+
method,
|
|
34330
|
+
error: error instanceof Error ? error.message : error
|
|
34331
|
+
});
|
|
34294
34332
|
if (error instanceof Error && error.name === "AbortError") {
|
|
34295
34333
|
return Result.err(new BBError({
|
|
34296
34334
|
code: 2001 /* API_REQUEST_FAILED */,
|
|
@@ -34472,6 +34510,10 @@ class PullRequestRepository {
|
|
|
34472
34510
|
async getDiffstat(workspace, repoSlug, id) {
|
|
34473
34511
|
return this.httpClient.get(this.buildPath(workspace, repoSlug, `/${id}/diffstat`));
|
|
34474
34512
|
}
|
|
34513
|
+
async listActivity(workspace, repoSlug, prId, limit = 25) {
|
|
34514
|
+
const safeLimit = Math.min(limit, API_PAGELEN_LIMITS.PULL_REQUESTS);
|
|
34515
|
+
return this.httpClient.get(`/repositories/${encodeURIComponent(workspace)}/${encodeURIComponent(repoSlug)}/pullrequests/${prId}/activity?pagelen=${safeLimit}`);
|
|
34516
|
+
}
|
|
34475
34517
|
async listComments(workspace, repoSlug, prId, limit = 25) {
|
|
34476
34518
|
const safeLimit = Math.min(limit, API_PAGELEN_LIMITS.PULL_REQUESTS);
|
|
34477
34519
|
return this.httpClient.get(`/repositories/${encodeURIComponent(workspace)}/${encodeURIComponent(repoSlug)}/pullrequests/${prId}/comments?pagelen=${safeLimit}`);
|
|
@@ -34991,6 +35033,9 @@ class CreatePRCommand extends BaseCommand {
|
|
|
34991
35033
|
if (options.closeSourceBranch) {
|
|
34992
35034
|
request.close_source_branch = true;
|
|
34993
35035
|
}
|
|
35036
|
+
if (options.draft) {
|
|
35037
|
+
request.draft = true;
|
|
35038
|
+
}
|
|
34994
35039
|
const result = await this.prRepository.create(workspace, repoSlug, request);
|
|
34995
35040
|
this.handleResult(result, context, (pr) => {
|
|
34996
35041
|
this.output.success(`Created pull request #${pr.id}`);
|
|
@@ -35030,12 +35075,15 @@ class ListPRsCommand extends BaseCommand {
|
|
|
35030
35075
|
this.output.text(`No ${state.toLowerCase()} pull requests found`);
|
|
35031
35076
|
return;
|
|
35032
35077
|
}
|
|
35033
|
-
const rows = data.values.map((pr) =>
|
|
35034
|
-
|
|
35035
|
-
|
|
35036
|
-
|
|
35037
|
-
|
|
35038
|
-
|
|
35078
|
+
const rows = data.values.map((pr) => {
|
|
35079
|
+
const title = pr.draft ? `[DRAFT] ${pr.title}` : pr.title;
|
|
35080
|
+
return [
|
|
35081
|
+
`#${pr.id}`,
|
|
35082
|
+
this.truncate(title, 50),
|
|
35083
|
+
pr.author.display_name,
|
|
35084
|
+
`${pr.source.branch.name} → ${pr.destination.branch.name}`
|
|
35085
|
+
];
|
|
35086
|
+
});
|
|
35039
35087
|
this.output.table(["ID", "TITLE", "AUTHOR", "BRANCHES"], rows);
|
|
35040
35088
|
});
|
|
35041
35089
|
return result;
|
|
@@ -35073,7 +35121,8 @@ class ViewPRCommand extends BaseCommand {
|
|
|
35073
35121
|
const result = await this.prRepository.get(workspace, repoSlug, prId);
|
|
35074
35122
|
this.handleResult(result, context, (pr) => {
|
|
35075
35123
|
const stateColor = this.getStateColor(pr.state);
|
|
35076
|
-
|
|
35124
|
+
const draftLabel = pr.draft ? source_default.yellow("[DRAFT]") : "";
|
|
35125
|
+
this.output.text(`${source_default.bold(`#${pr.id}`)} ${pr.title} ${stateColor(`[${pr.state}]`)}${draftLabel ? ` ${draftLabel}` : ""}`);
|
|
35077
35126
|
this.output.text("");
|
|
35078
35127
|
if (pr.description) {
|
|
35079
35128
|
this.output.text(pr.description);
|
|
@@ -35304,6 +35353,40 @@ class DeclinePRCommand extends BaseCommand {
|
|
|
35304
35353
|
}
|
|
35305
35354
|
}
|
|
35306
35355
|
|
|
35356
|
+
// src/commands/pr/ready.command.ts
|
|
35357
|
+
class ReadyPRCommand extends BaseCommand {
|
|
35358
|
+
prRepository;
|
|
35359
|
+
contextService;
|
|
35360
|
+
name = "ready";
|
|
35361
|
+
description = "Mark a draft pull request as ready for review";
|
|
35362
|
+
constructor(prRepository, contextService, output) {
|
|
35363
|
+
super(output);
|
|
35364
|
+
this.prRepository = prRepository;
|
|
35365
|
+
this.contextService = contextService;
|
|
35366
|
+
}
|
|
35367
|
+
async execute(options, context) {
|
|
35368
|
+
const repoContextResult = await this.contextService.requireRepoContext({
|
|
35369
|
+
...context.globalOptions,
|
|
35370
|
+
...options
|
|
35371
|
+
});
|
|
35372
|
+
if (!repoContextResult.success) {
|
|
35373
|
+
this.handleResult(repoContextResult, context);
|
|
35374
|
+
return repoContextResult;
|
|
35375
|
+
}
|
|
35376
|
+
const { workspace, repoSlug } = repoContextResult.value;
|
|
35377
|
+
const prId = parseInt(options.id, 10);
|
|
35378
|
+
const request = {
|
|
35379
|
+
draft: false
|
|
35380
|
+
};
|
|
35381
|
+
const result = await this.prRepository.update(workspace, repoSlug, prId, request);
|
|
35382
|
+
this.handleResult(result, context, (pr) => {
|
|
35383
|
+
this.output.success(`Marked pull request #${prId} as ready for review`);
|
|
35384
|
+
this.output.text(` ${pr.title}`);
|
|
35385
|
+
});
|
|
35386
|
+
return result;
|
|
35387
|
+
}
|
|
35388
|
+
}
|
|
35389
|
+
|
|
35307
35390
|
// src/commands/pr/checkout.command.ts
|
|
35308
35391
|
class CheckoutPRCommand extends BaseCommand {
|
|
35309
35392
|
prRepository;
|
|
@@ -35580,6 +35663,149 @@ class DiffPRCommand extends BaseCommand {
|
|
|
35580
35663
|
}
|
|
35581
35664
|
}
|
|
35582
35665
|
|
|
35666
|
+
// src/commands/pr/activity.command.ts
|
|
35667
|
+
class ActivityPRCommand extends BaseCommand {
|
|
35668
|
+
prRepository;
|
|
35669
|
+
contextService;
|
|
35670
|
+
name = "activity";
|
|
35671
|
+
description = "Show pull request activity history";
|
|
35672
|
+
constructor(prRepository, contextService, output) {
|
|
35673
|
+
super(output);
|
|
35674
|
+
this.prRepository = prRepository;
|
|
35675
|
+
this.contextService = contextService;
|
|
35676
|
+
}
|
|
35677
|
+
async execute(options, context) {
|
|
35678
|
+
const repoContextResult = await this.contextService.requireRepoContext({
|
|
35679
|
+
...context.globalOptions,
|
|
35680
|
+
...options
|
|
35681
|
+
});
|
|
35682
|
+
if (!repoContextResult.success) {
|
|
35683
|
+
this.handleResult(repoContextResult, context);
|
|
35684
|
+
return repoContextResult;
|
|
35685
|
+
}
|
|
35686
|
+
const { workspace, repoSlug } = repoContextResult.value;
|
|
35687
|
+
const prId = parseInt(options.id, 10);
|
|
35688
|
+
const limit = options.limit ? parseInt(options.limit, 10) : DEFAULT_PAGELEN.PULL_REQUESTS;
|
|
35689
|
+
const result = await this.prRepository.listActivity(workspace, repoSlug, prId, limit);
|
|
35690
|
+
this.handleResult(result, context, (data) => {
|
|
35691
|
+
const filterTypes = this.parseTypeFilter(options.type);
|
|
35692
|
+
const activities = filterTypes.length > 0 ? data.values.filter((activity) => filterTypes.includes(this.getActivityType(activity))) : data.values;
|
|
35693
|
+
if (activities.length === 0) {
|
|
35694
|
+
if (filterTypes.length > 0) {
|
|
35695
|
+
this.output.info("No activity entries matched the requested filter");
|
|
35696
|
+
} else {
|
|
35697
|
+
this.output.info("No activity found on this pull request");
|
|
35698
|
+
}
|
|
35699
|
+
return;
|
|
35700
|
+
}
|
|
35701
|
+
const rows = activities.map((activity) => {
|
|
35702
|
+
const activityType = this.getActivityType(activity);
|
|
35703
|
+
return [
|
|
35704
|
+
activityType.toUpperCase(),
|
|
35705
|
+
this.getActorName(activity),
|
|
35706
|
+
this.formatActivityDate(activity),
|
|
35707
|
+
this.buildActivityDetails(activity, activityType)
|
|
35708
|
+
];
|
|
35709
|
+
});
|
|
35710
|
+
this.output.table(["TYPE", "ACTOR", "DATE", "DETAILS"], rows);
|
|
35711
|
+
});
|
|
35712
|
+
return result;
|
|
35713
|
+
}
|
|
35714
|
+
parseTypeFilter(typeOption) {
|
|
35715
|
+
if (!typeOption) {
|
|
35716
|
+
return [];
|
|
35717
|
+
}
|
|
35718
|
+
return typeOption.split(",").map((type) => type.trim().toLowerCase()).filter((type) => type.length > 0);
|
|
35719
|
+
}
|
|
35720
|
+
getActivityType(activity) {
|
|
35721
|
+
if (activity.comment) {
|
|
35722
|
+
return "comment";
|
|
35723
|
+
}
|
|
35724
|
+
if (activity.approval) {
|
|
35725
|
+
return "approval";
|
|
35726
|
+
}
|
|
35727
|
+
if (activity.changes_requested) {
|
|
35728
|
+
return "changes_requested";
|
|
35729
|
+
}
|
|
35730
|
+
if (activity.merge) {
|
|
35731
|
+
return "merge";
|
|
35732
|
+
}
|
|
35733
|
+
if (activity.decline) {
|
|
35734
|
+
return "decline";
|
|
35735
|
+
}
|
|
35736
|
+
if (activity.commit) {
|
|
35737
|
+
return "commit";
|
|
35738
|
+
}
|
|
35739
|
+
if (activity.update) {
|
|
35740
|
+
return "update";
|
|
35741
|
+
}
|
|
35742
|
+
return activity.type ? activity.type.toLowerCase() : "activity";
|
|
35743
|
+
}
|
|
35744
|
+
getActorName(activity) {
|
|
35745
|
+
const user = activity.comment?.user ?? activity.comment?.author ?? activity.approval?.user ?? activity.update?.author ?? activity.changes_requested?.user ?? activity.merge?.user ?? activity.decline?.user ?? activity.commit?.author?.user ?? activity.user;
|
|
35746
|
+
if (!user) {
|
|
35747
|
+
return "Unknown";
|
|
35748
|
+
}
|
|
35749
|
+
return user.display_name || user.username || "Unknown";
|
|
35750
|
+
}
|
|
35751
|
+
formatActivityDate(activity) {
|
|
35752
|
+
const date = activity.comment?.created_on ?? activity.approval?.date ?? activity.update?.date ?? activity.changes_requested?.date ?? activity.merge?.date ?? activity.decline?.date ?? activity.commit?.date;
|
|
35753
|
+
if (!date) {
|
|
35754
|
+
return "-";
|
|
35755
|
+
}
|
|
35756
|
+
return this.output.formatDate(date);
|
|
35757
|
+
}
|
|
35758
|
+
buildActivityDetails(activity, type) {
|
|
35759
|
+
switch (type) {
|
|
35760
|
+
case "comment": {
|
|
35761
|
+
const content = activity.comment?.content?.raw ?? "";
|
|
35762
|
+
const id = activity.comment?.id ? `#${activity.comment.id}` : "";
|
|
35763
|
+
const snippet = this.truncate(content, 80);
|
|
35764
|
+
return [id, snippet].filter(Boolean).join(" ");
|
|
35765
|
+
}
|
|
35766
|
+
case "approval":
|
|
35767
|
+
return "approved";
|
|
35768
|
+
case "changes_requested": {
|
|
35769
|
+
const reason = activity.changes_requested?.reason;
|
|
35770
|
+
return reason ? this.truncate(reason, 80) : "changes requested";
|
|
35771
|
+
}
|
|
35772
|
+
case "merge":
|
|
35773
|
+
return this.formatCommitDetail(activity.merge?.commit?.hash, "merged");
|
|
35774
|
+
case "decline":
|
|
35775
|
+
return "declined";
|
|
35776
|
+
case "commit":
|
|
35777
|
+
return this.formatCommitDetail(activity.commit?.hash, "commit");
|
|
35778
|
+
case "update": {
|
|
35779
|
+
if (activity.update?.state) {
|
|
35780
|
+
return `state: ${activity.update.state}`;
|
|
35781
|
+
}
|
|
35782
|
+
if (activity.update?.title) {
|
|
35783
|
+
return `title: ${this.truncate(activity.update.title, 60)}`;
|
|
35784
|
+
}
|
|
35785
|
+
if (activity.update?.description) {
|
|
35786
|
+
return "description updated";
|
|
35787
|
+
}
|
|
35788
|
+
return "updated";
|
|
35789
|
+
}
|
|
35790
|
+
default:
|
|
35791
|
+
return "";
|
|
35792
|
+
}
|
|
35793
|
+
}
|
|
35794
|
+
formatCommitDetail(hash, label) {
|
|
35795
|
+
if (!hash) {
|
|
35796
|
+
return label ?? "";
|
|
35797
|
+
}
|
|
35798
|
+
const shortHash = hash.slice(0, 7);
|
|
35799
|
+
return label ? `${label} ${shortHash}` : shortHash;
|
|
35800
|
+
}
|
|
35801
|
+
truncate(text, maxLength) {
|
|
35802
|
+
if (text.length <= maxLength) {
|
|
35803
|
+
return text;
|
|
35804
|
+
}
|
|
35805
|
+
return text.substring(0, maxLength - 3) + "...";
|
|
35806
|
+
}
|
|
35807
|
+
}
|
|
35808
|
+
|
|
35583
35809
|
// src/commands/pr/comment.command.ts
|
|
35584
35810
|
class CommentPRCommand extends BaseCommand {
|
|
35585
35811
|
prRepository;
|
|
@@ -36015,6 +36241,12 @@ function bootstrap() {
|
|
|
36015
36241
|
const output = container.resolve(ServiceTokens.OutputService);
|
|
36016
36242
|
return new DeclinePRCommand(prRepo, contextService, output);
|
|
36017
36243
|
});
|
|
36244
|
+
container.register(ServiceTokens.ReadyPRCommand, () => {
|
|
36245
|
+
const prRepo = container.resolve(ServiceTokens.PullRequestRepository);
|
|
36246
|
+
const contextService = container.resolve(ServiceTokens.ContextService);
|
|
36247
|
+
const output = container.resolve(ServiceTokens.OutputService);
|
|
36248
|
+
return new ReadyPRCommand(prRepo, contextService, output);
|
|
36249
|
+
});
|
|
36018
36250
|
container.register(ServiceTokens.CheckoutPRCommand, () => {
|
|
36019
36251
|
const prRepo = container.resolve(ServiceTokens.PullRequestRepository);
|
|
36020
36252
|
const contextService = container.resolve(ServiceTokens.ContextService);
|
|
@@ -36029,6 +36261,12 @@ function bootstrap() {
|
|
|
36029
36261
|
const output = container.resolve(ServiceTokens.OutputService);
|
|
36030
36262
|
return new DiffPRCommand(prRepo, contextService, gitService, output);
|
|
36031
36263
|
});
|
|
36264
|
+
container.register(ServiceTokens.ActivityPRCommand, () => {
|
|
36265
|
+
const prRepo = container.resolve(ServiceTokens.PullRequestRepository);
|
|
36266
|
+
const contextService = container.resolve(ServiceTokens.ContextService);
|
|
36267
|
+
const output = container.resolve(ServiceTokens.OutputService);
|
|
36268
|
+
return new ActivityPRCommand(prRepo, contextService, output);
|
|
36269
|
+
});
|
|
36032
36270
|
container.register(ServiceTokens.CommentPRCommand, () => {
|
|
36033
36271
|
const prRepo = container.resolve(ServiceTokens.PullRequestRepository);
|
|
36034
36272
|
const contextService = container.resolve(ServiceTokens.ContextService);
|
|
@@ -36103,7 +36341,7 @@ if (process.argv.includes("--get-yargs-completions") || process.env.COMP_LINE) {
|
|
|
36103
36341
|
} else if (env2.prev === "repo") {
|
|
36104
36342
|
completions.push("clone", "create", "list", "view", "delete");
|
|
36105
36343
|
} else if (env2.prev === "pr") {
|
|
36106
|
-
completions.push("create", "list", "view", "edit", "merge", "approve", "decline", "checkout", "diff", "comments");
|
|
36344
|
+
completions.push("create", "list", "view", "activity", "edit", "merge", "approve", "decline", "ready", "checkout", "diff", "comments");
|
|
36107
36345
|
} else if (env2.prev === "config") {
|
|
36108
36346
|
completions.push("get", "set", "list");
|
|
36109
36347
|
} else if (env2.prev === "completion") {
|
|
@@ -36205,7 +36443,7 @@ repoCmd.command("delete <repository>").description("Delete a repository").option
|
|
|
36205
36443
|
});
|
|
36206
36444
|
cli.addCommand(repoCmd);
|
|
36207
36445
|
var prCmd = new Command("pr").description("Manage pull requests");
|
|
36208
|
-
prCmd.command("create").description("Create a pull request").option("-t, --title <title>", "Pull request title").option("-b, --body <body>", "Pull request description").option("-s, --source <branch>", "Source branch (default: current branch)").option("-d, --destination <branch>", "Destination branch (default: main)").option("--close-source-branch", "Close source branch after merge").action(async (options) => {
|
|
36446
|
+
prCmd.command("create").description("Create a pull request").option("-t, --title <title>", "Pull request title").option("-b, --body <body>", "Pull request description").option("-s, --source <branch>", "Source branch (default: current branch)").option("-d, --destination <branch>", "Destination branch (default: main)").option("--close-source-branch", "Close source branch after merge").option("--draft", "Create the pull request as draft").action(async (options) => {
|
|
36209
36447
|
const cmd = container.resolve(ServiceTokens.CreatePRCommand);
|
|
36210
36448
|
const context = createContext(cli);
|
|
36211
36449
|
const result = await cmd.execute(withGlobalOptions(options, context), context);
|
|
@@ -36229,6 +36467,14 @@ prCmd.command("view <id>").description("View pull request details").action(async
|
|
|
36229
36467
|
process.exit(1);
|
|
36230
36468
|
}
|
|
36231
36469
|
});
|
|
36470
|
+
prCmd.command("activity <id>").description("Show pull request activity log").option("--limit <number>", "Maximum number of activity entries", "25").option("--type <types>", "Filter activity by type (comma-separated)").action(async (id, options) => {
|
|
36471
|
+
const cmd = container.resolve(ServiceTokens.ActivityPRCommand);
|
|
36472
|
+
const context = createContext(cli);
|
|
36473
|
+
const result = await cmd.execute(withGlobalOptions({ id, ...options }, context), context);
|
|
36474
|
+
if (!result.success) {
|
|
36475
|
+
process.exit(1);
|
|
36476
|
+
}
|
|
36477
|
+
});
|
|
36232
36478
|
prCmd.command("edit [id]").description("Edit a pull request").option("-t, --title <title>", "New pull request title").option("-b, --body <body>", "New pull request description").option("-F, --body-file <file>", "Read description from file").action(async (id, options) => {
|
|
36233
36479
|
const cmd = container.resolve(ServiceTokens.EditPRCommand);
|
|
36234
36480
|
const context = createContext(cli);
|
|
@@ -36261,6 +36507,14 @@ prCmd.command("decline <id>").description("Decline a pull request").action(async
|
|
|
36261
36507
|
process.exit(1);
|
|
36262
36508
|
}
|
|
36263
36509
|
});
|
|
36510
|
+
prCmd.command("ready <id>").description("Mark a draft pull request as ready for review").action(async (id, options) => {
|
|
36511
|
+
const cmd = container.resolve(ServiceTokens.ReadyPRCommand);
|
|
36512
|
+
const context = createContext(cli);
|
|
36513
|
+
const result = await cmd.execute(withGlobalOptions({ id, ...options }, context), context);
|
|
36514
|
+
if (!result.success) {
|
|
36515
|
+
process.exit(1);
|
|
36516
|
+
}
|
|
36517
|
+
});
|
|
36264
36518
|
prCmd.command("checkout <id>").description("Checkout a pull request locally").action(async (id, options) => {
|
|
36265
36519
|
const cmd = container.resolve(ServiceTokens.CheckoutPRCommand);
|
|
36266
36520
|
const context = createContext(cli);
|