Skip to content

🎥 Make videos programmatically with React

@remotion/cli, @remotion/player: Fix gitSource subfolder for Vercel deployments, fix setVolume error message

copilot-swe-agent[bot]eb66e3fdd50a
diff --git a/packages/cli/src/get-github-repository.ts b/packages/cli/src/get-github-repository.ts
index 4cba19c3b4..87725cddbe 100644
--- a/packages/cli/src/get-github-repository.ts
+++ b/packages/cli/src/get-github-repository.ts
@@ -1,9 +1,9 @@
-import {execSync} from 'child_process';
-import {existsSync, readFileSync} from 'fs';
-import path from 'path';
import {BundlerInternals} from '@remotion/bundler';
import type {LogLevel} from '@remotion/renderer';
import type {GitSource} from '@remotion/studio-shared';
+import {execSync} from 'child_process';
+import {existsSync, readFileSync} from 'fs';
+import path from 'path';
import {Log} from './log';
export type ParsedGitRemote = {
@@ -112,7 +112,7 @@ export const getGifRef = (logLevel: LogLevel): string | null => {
}
};
-const getFromEnvVariables = (): GitSource | null => {
+const getFromEnvVariables = (remotionRoot: string): GitSource | null => {
const {
VERCEL_GIT_PROVIDER,
VERCEL_GIT_COMMIT_SHA,
@@ -125,12 +125,19 @@ const getFromEnvVariables = (): GitSource | null => {
VERCEL_GIT_REPO_SLUG &&
VERCEL_GIT_PROVIDER === 'github'
) {
+ let relativeFromGitRoot = '';
+ const gitConfig = getGitConfig(remotionRoot);
+ if (gitConfig) {
+ const gitRoot = path.dirname(path.dirname(gitConfig));
+ relativeFromGitRoot = path.relative(gitRoot, remotionRoot);
+ }
+
return {
name: VERCEL_GIT_REPO_SLUG,
org: VERCEL_GIT_REPO_OWNER,
ref: VERCEL_GIT_COMMIT_SHA,
type: 'github',
- relativeFromGitRoot: '',
+ relativeFromGitRoot,
};
}
@@ -150,9 +157,9 @@ export const getGitSource = ({
return null;
}
- const fromEnv = getFromEnvVariables();
+ const fromEnv = getFromEnvVariables(remotionRoot);
if (fromEnv) {
- return getFromEnvVariables();
+ return fromEnv;
}
const ref = getGifRef(logLevel);
diff --git a/packages/cli/src/test/get-github-repo.test.ts b/packages/cli/src/test/get-github-repo.test.ts
index 9c0b9c387b..dcfd0dd904 100644
--- a/packages/cli/src/test/get-github-repo.test.ts
+++ b/packages/cli/src/test/get-github-repo.test.ts
@@ -69,7 +69,7 @@ test('Should recognize VERCEL', () => {
process.env.VERCEL_GIT_REPO_OWNER = 'remotion-dev';
const source = getGitSource({
- remotionRoot: 'dontmatter',
+ remotionRoot: process.cwd(),
disableGitSource: false,
logLevel: 'info',
});
@@ -78,4 +78,10 @@ test('Should recognize VERCEL', () => {
expect(source?.org).toBe('remotion-dev');
expect(source?.ref).toBe('123');
expect(source?.type).toBe('github');
+ expect(source?.relativeFromGitRoot).toBe(`packages${path.sep}cli`);
+
+ delete process.env.VERCEL_GIT_COMMIT_SHA;
+ delete process.env.VERCEL_GIT_PROVIDER;
+ delete process.env.VERCEL_GIT_REPO_SLUG;
+ delete process.env.VERCEL_GIT_REPO_OWNER;
});
diff --git a/packages/player/src/PlayerUI.tsx b/packages/player/src/PlayerUI.tsx
index bbc6454678..9697a1ef66 100644
--- a/packages/player/src/PlayerUI.tsx
+++ b/packages/player/src/PlayerUI.tsx
@@ -439,7 +439,7 @@ const PlayerUI: React.ForwardRefRenderFunction<
if (vol < 0 || vol > 1) {
throw new TypeError(
- `setVolume() got a number that is out of range. Must be between 0 and 1, got ${typeof vol}`,
+ `setVolume() got a number that is out of range. Must be between 0 and 1, got ${vol}`,
);
}