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