Flesh out debug logs
This commit is contained in:
+9
-9
@@ -25,7 +25,7 @@ export type CheckoutPrResult = {
|
||||
* Assumes origin remote is already configured with authentication.
|
||||
*/
|
||||
export async function checkoutPrBranch(ctx: Context, pull_number: number): Promise<void> {
|
||||
log.info(`🔀 checking out PR #${pull_number}...`);
|
||||
log.debug(`🔀 checking out PR #${pull_number}...`);
|
||||
|
||||
// fetch PR metadata
|
||||
const pr = await ctx.octokit.rest.pulls.get({
|
||||
@@ -48,10 +48,10 @@ export async function checkoutPrBranch(ctx: Context, pull_number: number): Promi
|
||||
const alreadyOnBranch = currentBranch === headBranch;
|
||||
|
||||
if (alreadyOnBranch) {
|
||||
log.info(`already on PR branch ${headBranch}, skipping checkout`);
|
||||
log.debug(`already on PR branch ${headBranch}, skipping checkout`);
|
||||
} else {
|
||||
// fetch base branch so origin/<base> exists for diff operations
|
||||
log.info(`📥 fetching base branch (${baseBranch})...`);
|
||||
log.debug(`📥 fetching base branch (${baseBranch})...`);
|
||||
$("git", ["fetch", "--no-tags", "origin", baseBranch]);
|
||||
|
||||
// checkout base branch first to avoid "refusing to fetch into current branch" error
|
||||
@@ -59,18 +59,18 @@ export async function checkoutPrBranch(ctx: Context, pull_number: number): Promi
|
||||
$("git", ["checkout", "-B", baseBranch, `origin/${baseBranch}`]);
|
||||
|
||||
// fetch PR branch using pull/{n}/head refspec (works for both fork and same-repo PRs)
|
||||
log.info(`🌿 fetching PR #${pull_number} (${headBranch})...`);
|
||||
log.debug(`🌿 fetching PR #${pull_number} (${headBranch})...`);
|
||||
$("git", ["fetch", "--no-tags", "origin", `pull/${pull_number}/head:${headBranch}`]);
|
||||
|
||||
// checkout the branch
|
||||
$("git", ["checkout", headBranch]);
|
||||
log.info(`✓ checked out PR #${pull_number}`);
|
||||
log.debug(`✓ checked out PR #${pull_number}`);
|
||||
}
|
||||
|
||||
// ensure base branch is fetched (needed for diff operations)
|
||||
// fetch if we skipped checkout (already on branch) - otherwise already fetched above
|
||||
if (alreadyOnBranch) {
|
||||
log.info(`📥 fetching base branch (${baseBranch})...`);
|
||||
log.debug(`📥 fetching base branch (${baseBranch})...`);
|
||||
$("git", ["fetch", "--no-tags", "origin", baseBranch]);
|
||||
}
|
||||
|
||||
@@ -84,16 +84,16 @@ export async function checkoutPrBranch(ctx: Context, pull_number: number): Promi
|
||||
// add fork as a named remote (ignore error if already exists)
|
||||
try {
|
||||
$("git", ["remote", "add", remoteName, forkUrl]);
|
||||
log.info(`📌 added remote '${remoteName}' for fork ${headRepo.full_name}`);
|
||||
log.debug(`📌 added remote '${remoteName}' for fork ${headRepo.full_name}`);
|
||||
} catch {
|
||||
// remote already exists, update its URL
|
||||
$("git", ["remote", "set-url", remoteName, forkUrl]);
|
||||
log.info(`📌 updated remote '${remoteName}' for fork ${headRepo.full_name}`);
|
||||
log.debug(`📌 updated remote '${remoteName}' for fork ${headRepo.full_name}`);
|
||||
}
|
||||
|
||||
// set branch push config so `git push` knows where to push
|
||||
$("git", ["config", `branch.${headBranch}.pushRemote`, remoteName]);
|
||||
log.info(`📌 configured branch '${headBranch}' to push to '${remoteName}'`);
|
||||
log.debug(`📌 configured branch '${headBranch}' to push to '${remoteName}'`);
|
||||
|
||||
// warn if maintainer can't modify (push will likely fail)
|
||||
if (!pr.data.maintainer_can_modify) {
|
||||
|
||||
+5
-5
@@ -34,7 +34,7 @@ export function CreateBranchTool(ctx: Context) {
|
||||
);
|
||||
}
|
||||
|
||||
log.info(`Creating branch ${branchName} from ${resolvedBaseBranch}`);
|
||||
log.debug(`Creating branch ${branchName} from ${resolvedBaseBranch}`);
|
||||
|
||||
// fetch base branch to ensure we're up to date
|
||||
$("git", ["fetch", "origin", resolvedBaseBranch, "--depth=1"]);
|
||||
@@ -49,7 +49,7 @@ export function CreateBranchTool(ctx: Context) {
|
||||
// push branch to remote (set upstream)
|
||||
$("git", ["push", "-u", "origin", branchName]);
|
||||
|
||||
log.info(`Successfully created and pushed branch ${branchName}`);
|
||||
log.debug(`Successfully created and pushed branch ${branchName}`);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
@@ -109,7 +109,7 @@ export function CommitFilesTool(ctx: Context) {
|
||||
}
|
||||
|
||||
const currentBranch = $("git", ["rev-parse", "--abbrev-ref", "HEAD"], { log: false });
|
||||
log.info(`Committing files on branch ${currentBranch}`);
|
||||
log.debug(`Committing files on branch ${currentBranch}`);
|
||||
|
||||
// stage files if provided, otherwise stage all changes
|
||||
if (files.length > 0) {
|
||||
@@ -122,7 +122,7 @@ export function CommitFilesTool(ctx: Context) {
|
||||
$("git", ["commit", "-m", message]);
|
||||
|
||||
const commitSha = $("git", ["rev-parse", "HEAD"], { log: false });
|
||||
log.info(`Successfully committed: ${commitSha.substring(0, 7)}`);
|
||||
log.debug(`Successfully committed: ${commitSha.substring(0, 7)}`);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
@@ -162,7 +162,7 @@ export function PushBranchTool(_ctx: Context) {
|
||||
? ["push", "--force", "-u", remote, branch]
|
||||
: ["push", "-u", remote, branch];
|
||||
|
||||
log.info(`pushing branch ${branch} to ${remote}`);
|
||||
log.debug(`pushing branch ${branch} to ${remote}`);
|
||||
if (force) {
|
||||
log.warning(`force pushing - this will overwrite remote history`);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ export function PullRequestTool(ctx: Context) {
|
||||
parameters: PullRequest,
|
||||
execute: execute(ctx, async ({ title, body, base }) => {
|
||||
const currentBranch = $("git", ["rev-parse", "--abbrev-ref", "HEAD"], { log: false });
|
||||
log.info(`Current branch: ${currentBranch}`);
|
||||
log.debug(`Current branch: ${currentBranch}`);
|
||||
|
||||
// validate PR title and body for secrets
|
||||
if (containsSecrets(title) || containsSecrets(body)) {
|
||||
|
||||
Reference in New Issue
Block a user