sorenlouv / backport

A simple CLI tool that automates the process of backporting commits on a GitHub repo
https://github.com/sqren/backport/blob/main/docs/config-file-options.md
Apache License 2.0
247 stars 60 forks source link

SpawnError: No such remote on 9.6.0 #509

Closed Achllle closed 6 days ago

Achllle commented 2 weeks ago

When backporting on the latest version (9.6.0), I get the following error:

⚠️  Ouch! An unhandled error occured 😿
SpawnError: Code: 128, Args: "remote rm origin", Message: fatal: No such remote: 'origin'
    at ChildProcess.<anonymous> (/home/gmruser/.nvm/versions/node/v22.3.0/lib/node_modules/backport/dist/lib/child-process-promisified.js:53:29)
    at ChildProcess.emit (node:events:520:28)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5)
    at Process.callbackTrampoline (node:internal/async_hooks:130:17)
Please open an issue in https://github.com/sorenlouv/backport/issues or contact me directly on https://twitter.com/sorenlouv
For additional details see the logs: /home/gmruser/.backport/backport.info.log

This error does not occur on 9.5.1. It's odd since it seems to be the issue #505 is trying to resolve.

imphil commented 1 week ago

Can you post the full log (as mentioned in the last line) and the debug log at ~/backport/backport.debug.log, together with some information about the environment you're running in (git version, OS, locale, etc.)?

sorenlouv commented 1 week ago

Thanks for chiming in @imphil . Sounds like we may have to revert #505 unless we can find a better way of swallowing the exception when deleting a non-existing remote

Achllle commented 1 week ago

Sure thing. git remote -v

origin  git@github.com:Achllle/myrepo.git (fetch)
origin  git@github.com:Achllle/myrepo.git (push)
upstream        git@github.com:myorg/myrepo.git (fetch)
upstream        git@github.com:myorg/myrepo.git (push)

When I set fork: true in .backportrc.json, I get a similar error: SpawnError: Code: 128, Args: "remote rm Achllle", Message: fatal: No such remote: 'Achllle' It seems like the tool is using my username as the name of the fork, but my fork is named origin. This is a super common pattern so I'd say this is a (separate?) bug.

Debug logs for fork: false with some redundant/obvious stuff thrown out:

{"level":"info","message":"POST https://api.github.com/graphql (name:GithubConfigOptions, status: 200)","metadata":{},"timestamp":"2024-09-23 17:49:29"}
{"level":"verbose","message":"Query: query GithubConfigOptions($repoOwner: String!, $repoName: String!) {\n  viewer {\n    login\n  }\n  repository(owner: $repoOwner, name: $repoName) {\n    illegalBackportBranch: ref(qualifiedName: \"refs/heads/backport\") {\n      id\n    }\n    isPrivate\n    defaultBranchRef {\n      name\n      target {\n        ...RemoteConfigHistoryFragment\n      }\n    }\n  }\n}\n\nfragment RemoteConfigHistoryFragment on Commit {\n  remoteConfigHistory: history(first: 1, path: \".backportrc.json\") {\n    edges {\n      remoteConfig: node {\n        committedDate\n        file(path: \".backportrc.json\") {\n          ... on TreeEntry {\n            object {\n              ... on Blob {\n                text\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n}","metadata":{},"timestamp":"2024-09-23 17:49:29"}
{"level":"verbose","message":"Variables:","metadata":{"repoName":"myrepo","repoOwner":"myorg"},"timestamp":"2024-09-23 17:49:29"}
{"level":"verbose","message":"Response headers:","metadata":{"access-control-allow-origin":"*","access-control-expose-headers":"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset","content-security-policy":"default-src 'none'","content-type":"application/json; charset=utf-8","date":"Mon, 23 Sep 2024 17:49:29 GMT","github-authentication-token-expiration":"2024-12-31 08:00:00 UTC","referrer-policy":"origin-when-cross-origin, strict-origin-when-cross-origin","server":"github.com","strict-transport-security":"max-age=31536000; includeSubdomains; preload","transfer-encoding":"chunked","vary":"Accept-Encoding, Accept, X-Requested-With","x-accepted-oauth-scopes":"repo","x-content-type-options":"nosniff","x-frame-options":"deny","x-github-media-type":"github.v4","x-github-request-id":"C9D2:9F686:44E1EE1:45851F2:66F1AA29","x-oauth-scopes":"repo, workflow","x-ratelimit-limit":"5000","x-ratelimit-remaining":"4979","x-ratelimit-reset":"1727113880","x-ratelimit-resource":"graphql","x-ratelimit-used":"21","x-xss-protection":"0"},"timestamp":"2024-09-23 17:49:29"}
{"level":"verbose","message":"Response data:","metadata":{"data":{"repository":{"defaultBranchRef":{"name":"main","target":{"remoteConfigHistory":{"edges":[{"remoteConfig":{"committedDate":"2024-08-15T23:11:11Z","file":{"object":{"text":"// .backportrc.json\n{\n  // Required\n  \"repoOwner\": \"myorg\",\n  \"repoName\": \"myrepo\",\n  // the branches available to backport to\n  \"targetBranchChoices\": [\n    \"rc1.10\",\n    \"rc1.11\",\n    \"rc1.12\",\n    \"rc1.13\",\n    \"rc1.14\"\n  ],\n  // autoassign current user to backport PR\n  \"autoAssign\": true,\n  // Optional: Automatically detect which branches a pull request should be backported to based on the pull request labels.\n  // In this case, adding the label \"auto-backport-to-production\" will backport the PR to the \"production\" branch\n  \"branchLabelMapping\": {\n    \"^backport-to-(.+)$\": \"$1\"\n  },\n  // commit conflicts so the PR is force-created and can be resolved from github\n  \"commitConflicts\": true,\n  // copy the labels from the source PR to the backport PR(s)\n  \"copySourcePRLabels\": true,\n  // use the fork to create the backport branch in\n  \"fork\": true\n}"}}}}]}}},"illegalBackportBranch":null,"isPrivate":true},"viewer":{"login":"Achllle"}}},"timestamp":"2024-09-23 17:49:29"}
{"level":"info","message":"Running command: \"git --no-pager diff HEAD --name-only .backportrc.json\"","metadata":{},"timestamp":"2024-09-23 17:49:29"}
{"level":"info","message":"Running command: \"git ls-files .backportrc.json --exclude-standard --others\"","metadata":{},"timestamp":"2024-09-23 17:49:29"}
{"level":"info","message":"Running command: \"git --no-pager log -1 --format=%cd .backportrc.json\"","metadata":{},"timestamp":"2024-09-23 17:49:29"}
{"level":"verbose","message":"Spawn success: code=0 stderr= stdout=","metadata":{},"timestamp":"2024-09-23 17:49:29"}
{"level":"verbose","message":"Spawn success: code=0 stderr= stdout=","metadata":{},"timestamp":"2024-09-23 17:49:29"}
{"level":"verbose","message":"Spawn success: code=0 stderr= stdout=Thu Aug 15 23:11:11 2024 +0000\n","metadata":{},"timestamp":"2024-09-23 17:49:29"}
{"level":"info","message":"Remote config: Parsing.","metadata":{},"timestamp":"2024-09-23 17:49:29"}
{"level":"info","message":"Backporting options","metadata":{"accessToken":"<REDACTED>","assignees":[],"authenticatedUsername":"Achllle","author":"Achllle","autoAssign":true,"autoMerge":false,"autoMergeMethod":"merge","backportBinary":"backport","branchLabelMapping":{"^backport-to-(.+)$":"$1"},"cherrypickRef":true,"commitConflicts":true,"commitPaths":[],"copySourcePRLabels":true,"copySourcePRReviewers":false,"cwd":"/workspaces/dev-docker/ss/src/myrepo","dateSince":null,"dateUntil":null,"details":false,"draft":false,"fork":true,"gitHostname":"github.com","interactive":true,"isRepoPrivate":true,"maxNumber":10,"multipleBranches":true,"multipleCommits":false,"noVerify":true,"publishStatusCommentOnAbort":false,"publishStatusCommentOnFailure":false,"publishStatusCommentOnSuccess":true,"pullNumber":1732,"repoForkOwner":"Achllle","repoName":"myrepo","repoOwner":"myorg","resetAuthor":false,"reviewers":[],"signoff":false,"sourceBranch":"main","sourcePRLabels":[],"targetBranchChoices":["rc1.10","rc1.11","rc1.12","rc1.13","rc1.14"],"targetBranches":[],"targetPRLabels":[],"telemetry":true},"timestamp":"2024-09-23 17:49:29"}
{"level":"info","message":"POST https://api.github.com/graphql (name:CommitByPullNumber, status: 200)","metadata":{},"timestamp":"2024-09-23 17:49:30"}
{"level":"verbose","message":"Query: query CommitByPullNumber($repoOwner: String!, $repoName: String!, $pullNumber: Int!) {\n  repository(owner: $repoOwner, name: $repoName) {\n    pullRequest(number: $pullNumber) {\n      commits(last: 1) {\n        totalCount\n        edges {\n          node {\n            commit {\n              message\n            }\n          }\n        }\n      }\n      mergeCommit {\n        oid\n        committedDate\n        history(first: 2) {\n          edges {\n            node {\n              message\n              committedDate\n            }\n          }\n        }\n      }\n    }\n  }\n}","metadata":{},"timestamp":"2024-09-23 17:49:30"}
{"level":"verbose","message":"Variables:","metadata":{"pullNumber":1732,"repoName":"myrepo","repoOwner":"myorg"},"timestamp":"2024-09-23 17:49:30"}
{"level":"verbose","message":"Response headers:","metadata":{"access-control-allow-origin":"*","access-control-expose-headers":"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset","content-security-policy":"default-src 'none'","content-type":"application/json; charset=utf-8","date":"Mon, 23 Sep 2024 17:49:29 GMT","github-authentication-token-expiration":"2024-12-31 08:00:00 UTC","referrer-policy":"origin-when-cross-origin, strict-origin-when-cross-origin","server":"github.com","strict-transport-security":"max-age=31536000; includeSubdomains; preload","transfer-encoding":"chunked","vary":"Accept-Encoding, Accept, X-Requested-With","x-accepted-oauth-scopes":"repo","x-content-type-options":"nosniff","x-frame-options":"deny","x-github-media-type":"github.v4","x-github-request-id":"C9D2:9F686:44E2049:4585356:66F1AA29","x-oauth-scopes":"repo, workflow","x-ratelimit-limit":"5000","x-ratelimit-remaining":"4978","x-ratelimit-reset":"1727113880","x-ratelimit-resource":"graphql","x-ratelimit-used":"22","x-xss-protection":"0"},"timestamp":"2024-09-23 17:49:30"}
{"level":"verbose","message":"Response data:","metadata":{"data":{"repository":{"pullRequest":{"commits":{"edges":[{"node":{"commit":{"message":"Segm: Fix CMakelist"}}}],"totalCount":5},"mergeCommit":{"committedDate":"2024-09-21T01:40:42Z","history":{"edges":[{"node":{"committedDate":"2024-09-21T01:40:42Z","message":"Merge pull request #1732 from OrigPRUser/orig_branch_name\n\nMy PR title"}},{"node":{"committedDate":"2024-09-21T01:25:59Z","message":"Merge pull request #1678 from myorg/1667-parallelise-saving-debug\n\n1667 parallelise saving debug"}}]},"oid":"24e5d81ed42be5d88f9326ae4bdb3347d2ce9d44"}}}}},"timestamp":"2024-09-23 17:49:30"}
{"level":"info","message":"POST https://api.github.com/graphql (name:CommitsBySha, status: 200)","metadata":{},"timestamp":"2024-09-23 17:49:30"}
{"level":"verbose","message":"Query: query CommitsBySha($repoOwner: String!, $repoName: String!, $sha: String!) {\n  repository(owner: $repoOwner, name: $repoName) {\n    object(expression: $sha) {\n      ...SourceCommitWithTargetPullRequestFragment\n    }\n  }\n}\n\nfragment SourceCommitWithTargetPullRequestFragment on Commit {\n  repository {\n    name\n    owner {\n      login\n    }\n  }\n  sha: oid\n  message\n  committedDate\n  author {\n    name\n    email\n  }\n  associatedPullRequests(first: 1) {\n    edges {\n      node {\n        title\n        url\n        number\n        labels(first: 50) {\n          nodes {\n            name\n          }\n        }\n        baseRefName\n        mergeCommit {\n          ...RemoteConfigHistoryFragment\n          sha: oid\n          message\n        }\n        timelineItems(last: 20, itemTypes: CROSS_REFERENCED_EVENT) {\n          edges {\n            node {\n              ... on CrossReferencedEvent {\n                targetPullRequest: source {\n                  __typename\n                  ... on PullRequest {\n                    targetMergeCommit: mergeCommit {\n                      sha: oid\n                      message\n                    }\n                    repository {\n                      name\n                      owner {\n                        login\n                      }\n                    }\n                    url\n                    title\n                    state\n                    baseRefName\n                    number\n                    commits(first: 20) {\n                      edges {\n                        node {\n                          targetCommit: commit {\n                            message\n                            sha: oid\n                          }\n                        }\n                      }\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n}\n\nfragment RemoteConfigHistoryFragment on Commit {\n  remoteConfigHistory: history(first: 1, path: \".backportrc.json\") {\n    edges {\n      remoteConfig: node {\n        committedDate\n        file(path: \".backportrc.json\") {\n          ... on TreeEntry {\n            object {\n              ... on Blob {\n                text\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n}","metadata":{},"timestamp":"2024-09-23 17:49:30"}
{"level":"verbose","message":"Variables:","metadata":{"repoName":"myrepo","repoOwner":"myorg","sha":"24e5d81ed42be5d88f9326ae4bdb3347d2ce9d44"},"timestamp":"2024-09-23 17:49:30"}
{"level":"verbose","message":"Response headers:","metadata":{"access-control-allow-origin":"*","access-control-expose-headers":"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset","content-security-policy":"default-src 'none'","content-type":"application/json; charset=utf-8","date":"Mon, 23 Sep 2024 17:49:30 GMT","github-authentication-token-expiration":"2024-12-31 08:00:00 UTC","referrer-policy":"origin-when-cross-origin, strict-origin-when-cross-origin","server":"github.com","strict-transport-security":"max-age=31536000; includeSubdomains; preload","transfer-encoding":"chunked","vary":"Accept-Encoding, Accept, X-Requested-With","x-accepted-oauth-scopes":"repo","x-content-type-options":"nosniff","x-frame-options":"deny","x-github-media-type":"github.v4","x-github-request-id":"C9D2:9F686:44E2241:4585557:66F1AA2A","x-oauth-scopes":"repo, workflow","x-ratelimit-limit":"5000","x-ratelimit-remaining":"4977","x-ratelimit-reset":"1727113880","x-ratelimit-resource":"graphql","x-ratelimit-used":"23","x-xss-protection":"0"},"timestamp":"2024-09-23 17:49:30"}
{"level":"verbose","message":"Response data:","metadata":{"data":{"repository":{"object":{"associatedPullRequests":{"edges":[{"node":{"baseRefName":"main","labels":{"nodes":[{"name":"internal"},{"name":"size/s"}]},"mergeCommit":{"message":"Merge pull request #1732 from OrigPRUser/orig_branch_name\n\nMy PR title","remoteConfigHistory":{"edges":[{"remoteConfig":{"committedDate":"2024-08-15T23:11:11Z","file":{"object":{"text":"// .backportrc.json\n{\n  // Required\n  \"repoOwner\": \"myorg\",\n  \"repoName\": \"myrepo\",\n  // the branches available to backport to\n  \"targetBranchChoices\": [\n    \"rc1.10\",\n    \"rc1.11\",\n    \"rc1.12\",\n    \"rc1.13\",\n    \"rc1.14\"\n  ],\n  // autoassign current user to backport PR\n  \"autoAssign\": true,\n  // Optional: Automatically detect which branches a pull request should be backported to based on the pull request labels.\n  // In this case, adding the label \"auto-backport-to-production\" will backport the PR to the \"production\" branch\n  \"branchLabelMapping\": {\n    \"^backport-to-(.+)$\": \"$1\"\n  },\n  // commit conflicts so the PR is force-created and can be resolved from github\n  \"commitConflicts\": true,\n  // copy the labels from the source PR to the backport PR(s)\n  \"copySourcePRLabels\": true,\n  // use the fork to create the backport branch in\n  \"fork\": true\n}"}}}}]},"sha":"24e5d81ed42be5d88f9326ae4bdb3347d2ce9d44"},"number":1732,"timelineItems":{"edges":[]},"title":"My PR title","url":"https://github.com/myorg/myrepo/pull/1732"}}]},"author":{"email":"72277486+OrigPRUser@users.noreply.github.com","name":"OrigPRUser"},"committedDate":"2024-09-21T01:40:42Z","message":"Merge pull request #1732 from OrigPRUser/orig_branch_name\n\nMy PR title","repository":{"name":"myrepo","owner":{"login":"myorg"}},"sha":"24e5d81ed42be5d88f9326ae4bdb3347d2ce9d44"}}}},"timestamp":"2024-09-23 17:49:30"}
{"level":"info","message":"Commits","metadata":{"0":{"author":{"email":"72277486+OrigPRUser@users.noreply.github.com","name":"OrigPRUser"},"sourceBranch":"main","sourceCommit":{"branchLabelMapping":{"^backport-to-(.+)$":"$1"},"committedDate":"2024-09-21T01:40:42Z","message":"Merge pull request #1732 from OrigPRUser/orig_branch_name\n\nMy PR title","sha":"24e5d81ed42be5d88f9326ae4bdb3347d2ce9d44"},"sourcePullRequest":{"labels":["internal","size/s"],"mergeCommit":{"message":"Merge pull request #1732 from OrigPRUser/orig_branch_name\n\nMy PR title","sha":"24e5d81ed42be5d88f9326ae4bdb3347d2ce9d44"},"number":1732,"title":"My PR title","url":"https://github.com/myorg/myrepo/pull/1732"},"suggestedTargetBranches":[],"targetPullRequestStates":[]}},"timestamp":"2024-09-23 17:49:30"}
{"level":"info","message":"Target branches","metadata":{"0":"rc1.14"},"timestamp":"2024-09-23 17:49:37"}
{"level":"info","message":"Running command: \"git rev-parse --show-toplevel\"","metadata":{},"timestamp":"2024-09-23 17:49:37"}
{"level":"error","message":"An error occurred while retrieving git project root spawn git ENOENT","metadata":{"code":"ENOENT","errno":-2,"path":"git","spawnargs":["rev-parse","--show-toplevel"],"stack":"Error: spawn git ENOENT\n    at ChildProcess._handle.onexit (node:internal/child_process:286:19)\n    at onErrorNT (node:internal/child_process:484:16)\n    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)","syscall":"spawn git"},"timestamp":"2024-09-23 17:49:37"}
{"level":"debug","message":"repoPath=/home/myuser/.backport/repositories/myorg/myrepo, projectRoot=undefined","metadata":{},"timestamp":"2024-09-23 17:49:37"}
{"level":"info","message":"Running command: \"git remote --verbose\"","metadata":{},"timestamp":"2024-09-23 17:49:37"}
{"level":"verbose","message":"Error when running command: \"git rev-parse --show-toplevel\" Code: -2, Args: \"rev-parse --show-toplevel\", Message: ","metadata":{"context":{"cmdArgs":["rev-parse","--show-toplevel"],"code":-2,"stderr":"","stdout":""},"name":"SpawnError","stack":"SpawnError: Code: -2, Args: \"rev-parse --show-toplevel\", Message: \n    at ChildProcess.<anonymous> (/home/myuser/.nvm/versions/node/v22.3.0/lib/node_modules/backport/dist/lib/child-process-promisified.js:53:29)\n    at ChildProcess.emit (node:events:520:28)\n    at maybeClose (node:internal/child_process:1105:16)\n    at Socket.<anonymous> (node:internal/child_process:457:11)\n    at Socket.emit (node:events:520:28)\n    at Pipe.<anonymous> (node:net:339:12)\n    at Pipe.callbackTrampoline (node:internal/async_hooks:130:17)"},"timestamp":"2024-09-23 17:49:37"}
{"level":"verbose","message":"Spawn success: code=0 stderr= stdout=origin\tgit@github.com:Achllle/myrepo.git (fetch)\norigin\tgit@github.com:Achllle/myrepo.git (push)\nupstream\tgit@github.com:myorg/myrepo.git (fetch)\nupstream\tgit@github.com:myorg/myrepo.git (push)\n","metadata":{},"timestamp":"2024-09-23 17:49:37"}
{"level":"info","message":"Running command: \"git rev-parse --show-toplevel\"","metadata":{},"timestamp":"2024-09-23 17:49:37"}
{"level":"verbose","message":"Spawn success: code=0 stderr= stdout=/workspaces/dev-docker/ss/src/myrepo\n","metadata":{},"timestamp":"2024-09-23 17:49:37"}
{"level":"info","message":"Cloning repo from /workspaces/dev-docker/ss/src/myrepo to /home/myuser/.backport/repositories/myorg/myrepo","metadata":{},"timestamp":"2024-09-23 17:49:37"}
{"level":"verbose","message":"Cloning into '/home/myuser/.backport/repositories/myorg/myrepo'...\n","metadata":{},"timestamp":"2024-09-23 17:49:37"}
{"level":"verbose","message":"done.\n","metadata":{},"timestamp":"2024-09-23 17:49:38"}
{"level":"verbose","message":"Filtering content:   3% (3/89)\r","metadata":{},"timestamp":"2024-09-23 17:49:40"}
[...]
{"level":"verbose","message":"Filtering content:  98% (88/89), 562.35 MiB | 578.83 MiB/s\rFiltering content: 100% (89/89), 562.35 MiB | 578.83 MiB/s\rFiltering content: 100% (89/89), 680.50 MiB | 401.86 MiB/s, done.\n","metadata":{},"timestamp":"2024-09-23 17:49:40"}
{"level":"verbose","message":"Encountered 3 files that should have been pointers, but weren't:\n\tsrc/my_utilities/test/data/meshes/invalid_mesh.obj\n\tsrc/my_utilities/test/data/meshes/workpiece.dae\n\tsrc/my_utilities/test/data/meshes/workpiece.obj\n","metadata":{},"timestamp":"2024-09-23 17:49:40"}
{"level":"info","message":"Running command: \"git remote rm origin\"","metadata":{},"timestamp":"2024-09-23 17:49:40"}
{"level":"verbose","message":"Spawn success: code=0 stderr= stdout=","metadata":{},"timestamp":"2024-09-23 17:49:40"}
{"level":"info","message":"Running command: \"git remote rm Achllle\"","metadata":{},"timestamp":"2024-09-23 17:49:40"}
{"level":"verbose","message":"Error when running command: \"git remote rm Achllle\" Code: 128, Args: \"remote rm Achllle\", Message: fatal: No such remote: 'Achllle'","metadata":{"context":{"cmdArgs":["remote","rm","Achllle"],"code":128,"stderr":"fatal: No such remote: 'Achllle'\n","stdout":""},"name":"SpawnError","stack":"SpawnError: Code: 128, Args: \"remote rm Achllle\", Message: fatal: No such remote: 'Achllle'\n    at ChildProcess.<anonymous> (/home/myuser/.nvm/versions/node/v22.3.0/lib/node_modules/backport/dist/lib/child-process-promisified.js:53:29)\n    at ChildProcess.emit (node:events:520:28)\n    at maybeClose (node:internal/child_process:1105:16)\n    at ChildProcess._handle.onexit (node:internal/child_process:305:5)\n    at Process.callbackTrampoline (node:internal/async_hooks:130:17)"},"timestamp":"2024-09-23 17:49:40"}
{"level":"error","message":"Unhandled exception: Code: 128, Args: \"remote rm Achllle\", Message: fatal: No such remote: 'Achllle'","metadata":{"context":{"cmdArgs":["remote","rm","Achllle"],"code":128,"stderr":"fatal: No such remote: 'Achllle'\n","stdout":""},"name":"SpawnError","stack":"SpawnError: Code: 128, Args: \"remote rm Achllle\", Message: fatal: No such remote: 'Achllle'\n    at ChildProcess.<anonymous> (/home/myuser/.nvm/versions/node/v22.3.0/lib/node_modules/backport/dist/lib/child-process-promisified.js:53:29)\n    at ChildProcess.emit (node:events:520:28)\n    at maybeClose (node:internal/child_process:1105:16)\n    at ChildProcess._handle.onexit (node:internal/child_process:305:5)\n    at Process.callbackTrampoline (node:internal/async_hooks:130:17)"},"timestamp":"2024-09-23 17:49:40"}
{"level":"info","message":"POST https://api.github.com/graphql (name:GithubConfigOptions, status: 200)","metadata":{},"timestamp":"2024-09-23 17:54:18"}
{"level":"verbose","message":"Query: query GithubConfigOptions($repoOwner: String!, $repoName: String!) {\n  viewer {\n    login\n  }\n  repository(owner: $repoOwner, name: $repoName) {\n    illegalBackportBranch: ref(qualifiedName: \"refs/heads/backport\") {\n      id\n    }\n    isPrivate\n    defaultBranchRef {\n      name\n      target {\n        ...RemoteConfigHistoryFragment\n      }\n    }\n  }\n}\n\nfragment RemoteConfigHistoryFragment on Commit {\n  remoteConfigHistory: history(first: 1, path: \".backportrc.json\") {\n    edges {\n      remoteConfig: node {\n        committedDate\n        file(path: \".backportrc.json\") {\n          ... on TreeEntry {\n            object {\n              ... on Blob {\n                text\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n}","metadata":{},"timestamp":"2024-09-23 17:54:18"}
{"level":"verbose","message":"Variables:","metadata":{"repoName":"myrepo","repoOwner":"myorg"},"timestamp":"2024-09-23 17:54:18"}
{"level":"verbose","message":"Response headers:","metadata":{"access-control-allow-origin":"*","access-control-expose-headers":"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset","content-security-policy":"default-src 'none'","content-type":"application/json; charset=utf-8","date":"Mon, 23 Sep 2024 17:54:18 GMT","github-authentication-token-expiration":"2024-12-31 08:00:00 UTC","referrer-policy":"origin-when-cross-origin, strict-origin-when-cross-origin","server":"github.com","strict-transport-security":"max-age=31536000; includeSubdomains; preload","transfer-encoding":"chunked","vary":"Accept-Encoding, Accept, X-Requested-With","x-accepted-oauth-scopes":"repo","x-content-type-options":"nosniff","x-frame-options":"deny","x-github-media-type":"github.v4","x-github-request-id":"C650:1070FC:B175C6:155ECF7:66F1AB4A","x-oauth-scopes":"repo, workflow","x-ratelimit-limit":"5000","x-ratelimit-remaining":"4999","x-ratelimit-reset":"1727117658","x-ratelimit-resource":"graphql","x-ratelimit-used":"1","x-xss-protection":"0"},"timestamp":"2024-09-23 17:54:18"}
{"level":"verbose","message":"Response data:","metadata":{"data":{"repository":{"defaultBranchRef":{"name":"main","target":{"remoteConfigHistory":{"edges":[{"remoteConfig":{"committedDate":"2024-08-15T23:11:11Z","file":{"object":{"text":"// .backportrc.json\n{\n  // Required\n  \"repoOwner\": \"myorg\",\n  \"repoName\": \"myrepo\",\n  // the branches available to backport to\n  \"targetBranchChoices\": [\n    \"rc1.10\",\n    \"rc1.11\",\n    \"rc1.12\",\n    \"rc1.13\",\n    \"rc1.14\"\n  ],\n  // autoassign current user to backport PR\n  \"autoAssign\": true,\n  // Optional: Automatically detect which branches a pull request should be backported to based on the pull request labels.\n  // In this case, adding the label \"auto-backport-to-production\" will backport the PR to the \"production\" branch\n  \"branchLabelMapping\": {\n    \"^backport-to-(.+)$\": \"$1\"\n  },\n  // commit conflicts so the PR is force-created and can be resolved from github\n  \"commitConflicts\": true,\n  // copy the labels from the source PR to the backport PR(s)\n  \"copySourcePRLabels\": true,\n  // use the fork to create the backport branch in\n  \"fork\": true\n}"}}}}]}}},"illegalBackportBranch":null,"isPrivate":true},"viewer":{"login":"Achllle"}}},"timestamp":"2024-09-23 17:54:18"}
{"level":"info","message":"Running command: \"git --no-pager diff HEAD --name-only .backportrc.json\"","metadata":{},"timestamp":"2024-09-23 17:54:18"}
{"level":"info","message":"Running command: \"git ls-files .backportrc.json --exclude-standard --others\"","metadata":{},"timestamp":"2024-09-23 17:54:18"}
{"level":"info","message":"Running command: \"git --no-pager log -1 --format=%cd .backportrc.json\"","metadata":{},"timestamp":"2024-09-23 17:54:18"}
{"level":"verbose","message":"Spawn success: code=0 stderr= stdout=.backportrc.json\n","metadata":{},"timestamp":"2024-09-23 17:54:18"}
{"level":"verbose","message":"Spawn success: code=0 stderr= stdout=","metadata":{},"timestamp":"2024-09-23 17:54:18"}
{"level":"verbose","message":"Spawn success: code=0 stderr= stdout=Thu Aug 15 23:11:11 2024 +0000\n","metadata":{},"timestamp":"2024-09-23 17:54:18"}
{"level":"info","message":"Remote config: Skipping. Local config is modified","metadata":{},"timestamp":"2024-09-23 17:54:18"}
{"level":"info","message":"Backporting options","metadata":{"accessToken":"<REDACTED>","assignees":[],"authenticatedUsername":"Achllle","author":"Achllle","autoAssign":true,"autoMerge":false,"autoMergeMethod":"merge","backportBinary":"backport","branchLabelMapping":{"^backport-to-(.+)$":"$1"},"cherrypickRef":true,"commitConflicts":true,"commitPaths":[],"copySourcePRLabels":true,"copySourcePRReviewers":false,"cwd":"/workspaces/dev-docker/ss/src/myrepo","dateSince":null,"dateUntil":null,"details":false,"draft":false,"fork":false,"gitHostname":"github.com","interactive":true,"isRepoPrivate":true,"maxNumber":10,"multipleBranches":true,"multipleCommits":false,"noVerify":true,"publishStatusCommentOnAbort":false,"publishStatusCommentOnFailure":false,"publishStatusCommentOnSuccess":true,"pullNumber":1732,"repoForkOwner":"Achllle","repoName":"myrepo","repoOwner":"myorg","resetAuthor":false,"reviewers":[],"signoff":false,"sourceBranch":"main","sourcePRLabels":[],"targetBranchChoices":["rc1.10","rc1.11","rc1.12","rc1.13","rc1.14"],"targetBranches":[],"targetPRLabels":[],"telemetry":true},"timestamp":"2024-09-23 17:54:18"}
{"level":"info","message":"POST https://api.github.com/graphql (name:CommitByPullNumber, status: 200)","metadata":{},"timestamp":"2024-09-23 17:54:18"}
{"level":"verbose","message":"Query: query CommitByPullNumber($repoOwner: String!, $repoName: String!, $pullNumber: Int!) {\n  repository(owner: $repoOwner, name: $repoName) {\n    pullRequest(number: $pullNumber) {\n      commits(last: 1) {\n        totalCount\n        edges {\n          node {\n            commit {\n              message\n            }\n          }\n        }\n      }\n      mergeCommit {\n        oid\n        committedDate\n        history(first: 2) {\n          edges {\n            node {\n              message\n              committedDate\n            }\n          }\n        }\n      }\n    }\n  }\n}","metadata":{},"timestamp":"2024-09-23 17:54:18"}
{"level":"verbose","message":"Variables:","metadata":{"pullNumber":1732,"repoName":"myrepo","repoOwner":"myorg"},"timestamp":"2024-09-23 17:54:18"}
{"level":"verbose","message":"Response headers:","metadata":{"access-control-allow-origin":"*","access-control-expose-headers":"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset","content-security-policy":"default-src 'none'","content-type":"application/json; charset=utf-8","date":"Mon, 23 Sep 2024 17:54:18 GMT","github-authentication-token-expiration":"2024-12-31 08:00:00 UTC","referrer-policy":"origin-when-cross-origin, strict-origin-when-cross-origin","server":"github.com","strict-transport-security":"max-age=31536000; includeSubdomains; preload","transfer-encoding":"chunked","vary":"Accept-Encoding, Accept, X-Requested-With","x-accepted-oauth-scopes":"repo","x-content-type-options":"nosniff","x-frame-options":"deny","x-github-media-type":"github.v4","x-github-request-id":"C650:1070FC:B177C4:155F0E1:66F1AB4A","x-oauth-scopes":"repo, workflow","x-ratelimit-limit":"5000","x-ratelimit-remaining":"4998","x-ratelimit-reset":"1727117658","x-ratelimit-resource":"graphql","x-ratelimit-used":"2","x-xss-protection":"0"},"timestamp":"2024-09-23 17:54:18"}
{"level":"verbose","message":"Response data:","metadata":{"data":{"repository":{"pullRequest":{"commits":{"edges":[{"node":{"commit":{"message":"Segm: Fix CMakelist"}}}],"totalCount":5},"mergeCommit":{"committedDate":"2024-09-21T01:40:42Z","history":{"edges":[{"node":{"committedDate":"2024-09-21T01:40:42Z","message":"Merge pull request #1732 from OrigPRUser/orig_branch_name\n\nMy PR title"}},{"node":{"committedDate":"2024-09-21T01:25:59Z","message":"Merge pull request #1678 from myorg/1667-parallelise-saving-debug\n\n1667 parallelise saving debug"}}]},"oid":"24e5d81ed42be5d88f9326ae4bdb3347d2ce9d44"}}}}},"timestamp":"2024-09-23 17:54:18"}
{"level":"info","message":"POST https://api.github.com/graphql (name:CommitsBySha, status: 200)","metadata":{},"timestamp":"2024-09-23 17:54:19"}
{"level":"verbose","message":"Query: query CommitsBySha($repoOwner: String!, $repoName: String!, $sha: String!) {\n  repository(owner: $repoOwner, name: $repoName) {\n    object(expression: $sha) {\n      ...SourceCommitWithTargetPullRequestFragment\n    }\n  }\n}\n\nfragment SourceCommitWithTargetPullRequestFragment on Commit {\n  repository {\n    name\n    owner {\n      login\n    }\n  }\n  sha: oid\n  message\n  committedDate\n  author {\n    name\n    email\n  }\n  associatedPullRequests(first: 1) {\n    edges {\n      node {\n        title\n        url\n        number\n        labels(first: 50) {\n          nodes {\n            name\n          }\n        }\n        baseRefName\n        mergeCommit {\n          ...RemoteConfigHistoryFragment\n          sha: oid\n          message\n        }\n        timelineItems(last: 20, itemTypes: CROSS_REFERENCED_EVENT) {\n          edges {\n            node {\n              ... on CrossReferencedEvent {\n                targetPullRequest: source {\n                  __typename\n                  ... on PullRequest {\n                    targetMergeCommit: mergeCommit {\n                      sha: oid\n                      message\n                    }\n                    repository {\n                      name\n                      owner {\n                        login\n                      }\n                    }\n                    url\n                    title\n                    state\n                    baseRefName\n                    number\n                    commits(first: 20) {\n                      edges {\n                        node {\n                          targetCommit: commit {\n                            message\n                            sha: oid\n                          }\n                        }\n                      }\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n}\n\nfragment RemoteConfigHistoryFragment on Commit {\n  remoteConfigHistory: history(first: 1, path: \".backportrc.json\") {\n    edges {\n      remoteConfig: node {\n        committedDate\n        file(path: \".backportrc.json\") {\n          ... on TreeEntry {\n            object {\n              ... on Blob {\n                text\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n}","metadata":{},"timestamp":"2024-09-23 17:54:19"}
{"level":"verbose","message":"Variables:","metadata":{"repoName":"myrepo","repoOwner":"myorg","sha":"24e5d81ed42be5d88f9326ae4bdb3347d2ce9d44"},"timestamp":"2024-09-23 17:54:19"}
{"level":"verbose","message":"Response headers:","metadata":{"access-control-allow-origin":"*","access-control-expose-headers":"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset","content-security-policy":"default-src 'none'","content-type":"application/json; charset=utf-8","date":"Mon, 23 Sep 2024 17:54:19 GMT","github-authentication-token-expiration":"2024-12-31 08:00:00 UTC","referrer-policy":"origin-when-cross-origin, strict-origin-when-cross-origin","server":"github.com","strict-transport-security":"max-age=31536000; includeSubdomains; preload","transfer-encoding":"chunked","vary":"Accept-Encoding, Accept, X-Requested-With","x-accepted-oauth-scopes":"repo","x-content-type-options":"nosniff","x-frame-options":"deny","x-github-media-type":"github.v4","x-github-request-id":"C650:1070FC:B178AB:155F28A:66F1AB4A","x-oauth-scopes":"repo, workflow","x-ratelimit-limit":"5000","x-ratelimit-remaining":"4997","x-ratelimit-reset":"1727117658","x-ratelimit-resource":"graphql","x-ratelimit-used":"3","x-xss-protection":"0"},"timestamp":"2024-09-23 17:54:19"}
{"level":"verbose","message":"Response data:","metadata":{"data":{"repository":{"object":{"associatedPullRequests":{"edges":[{"node":{"baseRefName":"main","labels":{"nodes":[{"name":"internal"},{"name":"size/s"}]},"mergeCommit":{"message":"Merge pull request #1732 from OrigPRUser/orig_branch_name\n\nMy PR title","remoteConfigHistory":{"edges":[{"remoteConfig":{"committedDate":"2024-08-15T23:11:11Z","file":{"object":{"text":"// .backportrc.json\n{\n  // Required\n  \"repoOwner\": \"myorg\",\n  \"repoName\": \"myrepo\",\n  // the branches available to backport to\n  \"targetBranchChoices\": [\n    \"rc1.10\",\n    \"rc1.11\",\n    \"rc1.12\",\n    \"rc1.13\",\n    \"rc1.14\"\n  ],\n  // autoassign current user to backport PR\n  \"autoAssign\": true,\n  // Optional: Automatically detect which branches a pull request should be backported to based on the pull request labels.\n  // In this case, adding the label \"auto-backport-to-production\" will backport the PR to the \"production\" branch\n  \"branchLabelMapping\": {\n    \"^backport-to-(.+)$\": \"$1\"\n  },\n  // commit conflicts so the PR is force-created and can be resolved from github\n  \"commitConflicts\": true,\n  // copy the labels from the source PR to the backport PR(s)\n  \"copySourcePRLabels\": true,\n  // use the fork to create the backport branch in\n  \"fork\": true\n}"}}}}]},"sha":"24e5d81ed42be5d88f9326ae4bdb3347d2ce9d44"},"number":1732,"timelineItems":{"edges":[]},"title":"My PR title","url":"https://github.com/myorg/myrepo/pull/1732"}}]},"author":{"email":"72277486+OrigPRUser@users.noreply.github.com","name":"OrigPRUser"},"committedDate":"2024-09-21T01:40:42Z","message":"Merge pull request #1732 from OrigPRUser/orig_branch_name\n\nMy PR title","repository":{"name":"myrepo","owner":{"login":"myorg"}},"sha":"24e5d81ed42be5d88f9326ae4bdb3347d2ce9d44"}}}},"timestamp":"2024-09-23 17:54:19"}
{"level":"info","message":"Commits","metadata":{"0":{"author":{"email":"72277486+OrigPRUser@users.noreply.github.com","name":"OrigPRUser"},"sourceBranch":"main","sourceCommit":{"branchLabelMapping":{"^backport-to-(.+)$":"$1"},"committedDate":"2024-09-21T01:40:42Z","message":"Merge pull request #1732 from OrigPRUser/orig_branch_name\n\nMy PR title","sha":"24e5d81ed42be5d88f9326ae4bdb3347d2ce9d44"},"sourcePullRequest":{"labels":["internal","size/s"],"mergeCommit":{"message":"Merge pull request #1732 from OrigPRUser/orig_branch_name\n\nMy PR title","sha":"24e5d81ed42be5d88f9326ae4bdb3347d2ce9d44"},"number":1732,"title":"My PR title","url":"https://github.com/myorg/myrepo/pull/1732"},"suggestedTargetBranches":[],"targetPullRequestStates":[]}},"timestamp":"2024-09-23 17:54:19"}
{"level":"info","message":"Target branches","metadata":{"0":"rc1.14"},"timestamp":"2024-09-23 17:54:28"}
{"level":"info","message":"Running command: \"git rev-parse --show-toplevel\"","metadata":{},"timestamp":"2024-09-23 17:54:28"}
{"level":"verbose","message":"Spawn success: code=0 stderr= stdout=/home/myuser/.backport/repositories/myorg/myrepo\n","metadata":{},"timestamp":"2024-09-23 17:54:28"}
{"level":"debug","message":"repoPath=/home/myuser/.backport/repositories/myorg/myrepo, projectRoot=/home/myuser/.backport/repositories/myorg/myrepo","metadata":{},"timestamp":"2024-09-23 17:54:28"}
{"level":"info","message":"Running command: \"git remote rm origin\"","metadata":{},"timestamp":"2024-09-23 17:54:28"}
{"level":"verbose","message":"Error when running command: \"git remote rm origin\" Code: 128, Args: \"remote rm origin\", Message: fatal: No such remote: 'origin'","metadata":{"context":{"cmdArgs":["remote","rm","origin"],"code":128,"stderr":"fatal: No such remote: 'origin'\n","stdout":""},"name":"SpawnError","stack":"SpawnError: Code: 128, Args: \"remote rm origin\", Message: fatal: No such remote: 'origin'\n    at ChildProcess.<anonymous> (/home/myuser/.nvm/versions/node/v22.3.0/lib/node_modules/backport/dist/lib/child-process-promisified.js:53:29)\n    at ChildProcess.emit (node:events:520:28)\n    at maybeClose (node:internal/child_process:1105:16)\n    at ChildProcess._handle.onexit (node:internal/child_process:305:5)\n    at Process.callbackTrampoline (node:internal/async_hooks:130:17)"},"timestamp":"2024-09-23 17:54:28"}
{"level":"error","message":"Unhandled exception: Code: 128, Args: \"remote rm origin\", Message: fatal: No such remote: 'origin'","metadata":{"context":{"cmdArgs":["remote","rm","origin"],"code":128,"stderr":"fatal: No such remote: 'origin'\n","stdout":""},"name":"SpawnError","stack":"SpawnError: Code: 128, Args: \"remote rm origin\", Message: fatal: No such remote: 'origin'\n    at ChildProcess.<anonymous> (/home/myuser/.nvm/versions/node/v22.3.0/lib/node_modules/backport/dist/lib/child-process-promisified.js:53:29)\n    at ChildProcess.emit (node:events:520:28)\n    at maybeClose (node:internal/child_process:1105:16)\n    at ChildProcess._handle.onexit (node:internal/child_process:305:5)\n    at Process.callbackTrampoline (node:internal/async_hooks:130:17)"},"timestamp":"2024-09-23 17:54:28"}

git --version

git version 2.25.1

locale

LANG=C.UTF-8
LANGUAGE=
LC_CTYPE="C.UTF-8"
LC_NUMERIC="C.UTF-8"
LC_TIME="C.UTF-8"
LC_COLLATE="C.UTF-8"
LC_MONETARY="C.UTF-8"
LC_MESSAGES="C.UTF-8"
LC_PAPER="C.UTF-8"
LC_NAME="C.UTF-8"
LC_ADDRESS="C.UTF-8"
LC_TELEPHONE="C.UTF-8"
LC_MEASUREMENT="C.UTF-8"
LC_IDENTIFICATION="C.UTF-8"
LC_ALL=C.UTF-8

Running in docker, Ubuntu 20.04 image

imphil commented 1 week ago

OK, that explains things: git remote only returns a 2 return code sine v2.30.0 (https://github.com/git/git/commit/9144ba4cf52bb0e891d7c10a331fc32c1d3e8f64). I'll do a PR to go back to stderr parsing for as long as these versions of git are around.

imphil commented 1 week ago

@Achllle Are you able to give the changes in https://github.com/sorenlouv/backport/pull/514 a try?

Achllle commented 6 days ago

Tried building this but got a yarn: error: no such option: --branch when trying to follow the instructions in CONTRIBUTING.md. I'm new when it comes to typescript programming. I'm assuming you tested with the older version of git in which case I'd guess it's fine.

sorenlouv commented 6 days ago

Tried building this but got a yarn: error: no such option: --branch when trying to follow the instructions in CONTRIBUTING.md. I'm new when it comes to typescript programming. I'm assuming you tested with the older version of git in which case I'd guess it's fine.

what command did you run that gave that error?

sorenlouv commented 6 days ago

A fix for this issue was published in v9.6.1.

@Achllle please try 9.6.1 and let us know how that goes. Thanks!

Achllle commented 6 days ago

what command did you run that gave that error?

I followed the CONTRIBUTING.md after checking out imphil:delete-remote-git-before-2.30:

yarn start --branch delete-remote-git-before-2.30 --repo backport-org/backport-demo --all
Achllle commented 6 days ago

A fix for this issue was published in v9.6.1.

@Achllle please try 9.6.1 and let us know how that goes. Thanks!

Seems like that did the trick!