@mastra/platform-workspace 1.5.0-alpha.2 → 1.5.0-alpha.3

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/dist/index.cjs CHANGED
@@ -2103,7 +2103,50 @@ function redactSecrets(value) {
2103
2103
  function gitAuthFlag() {
2104
2104
  return `-c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$${BUILD_TOKEN_ENV}" | base64 -w0)"`;
2105
2105
  }
2106
- async function resolveDefaultBranchHead(cloneUrl, token, execute = execFileAsync) {
2106
+ /**
2107
+ * `owner/repo` for a github.com clone URL, else undefined. Only the public
2108
+ * host is API-resolvable: GitHub Enterprise and other forges keep the git
2109
+ * path below.
2110
+ */
2111
+ function parseGithubRepo(cloneUrl) {
2112
+ let url;
2113
+ try {
2114
+ url = new URL(cloneUrl);
2115
+ } catch {
2116
+ return;
2117
+ }
2118
+ if (url.hostname.toLowerCase() !== "github.com") return void 0;
2119
+ const [owner, repo, ...rest] = url.pathname.split("/").filter(Boolean);
2120
+ if (!owner || !repo || rest.length > 0) return void 0;
2121
+ return {
2122
+ owner,
2123
+ repo: repo.replace(/\.git$/i, "")
2124
+ };
2125
+ }
2126
+ /**
2127
+ * Resolve the default-branch head. github.com repositories go through the
2128
+ * REST API so resolution works wherever the host runs, including deployed
2129
+ * images without a git binary; other hosts shell out to `git ls-remote`.
2130
+ * Throws with a redaction-safe message when the head cannot be resolved.
2131
+ */
2132
+ async function resolveDefaultBranchHead(cloneUrl, token, execute = execFileAsync, fetchImpl = fetch) {
2133
+ const github = parseGithubRepo(cloneUrl);
2134
+ if (github) {
2135
+ const response = await fetchImpl(`https://api.github.com/repos/${github.owner}/${github.repo}/commits/HEAD`, {
2136
+ headers: {
2137
+ Accept: "application/vnd.github.sha",
2138
+ "X-GitHub-Api-Version": "2022-11-28",
2139
+ "User-Agent": "mastra-platform-workspace",
2140
+ ...token ? { Authorization: `Bearer ${token}` } : {}
2141
+ },
2142
+ signal: AbortSignal.timeout(1e4)
2143
+ }).catch((error) => {
2144
+ throw new Error(`GitHub head lookup failed: ${error instanceof Error ? error.message : String(error)}`);
2145
+ });
2146
+ if (!response.ok) throw new Error(`GitHub head lookup failed: ${response.status} ${response.statusText}`.trim());
2147
+ const sha = (await response.text()).trim();
2148
+ return SHA_PATTERN.test(sha) ? sha : void 0;
2149
+ }
2107
2150
  try {
2108
2151
  const env = {
2109
2152
  ...process.env,