From a1565c1a25d8abb9efb1c7abf513ed1cb5e750d1 Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Tue, 24 Dec 2024 20:52:35 +0000 Subject: [PATCH 1/5] link to diff in version warning --- docs/_worker.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/_worker.js b/docs/_worker.js index 333f6268c7..937e21f9e6 100644 --- a/docs/_worker.js +++ b/docs/_worker.js @@ -46,7 +46,8 @@ async function versionWarning(request, env) { const text = await r2.text() throw new Error(`Failed to fetch compare, response status ${r2.status}:\n${text}`) } - const {ahead_by} = await r2.json() + const r2_data = await r2.json() + const {ahead_by} = r2_data if (ahead_by === 0) { return `
@@ -59,7 +60,8 @@ async function versionWarning(request, env) {

Version Notice

${env.CF_PAGES_BRANCH === 'main' ? '' : `(${env.CF_PAGES_BRANCH} preview)`} - This documentation is ahead of the last release by ${ahead_by} commit${ahead_by === 1 ? '' : 's'}. + This documentation is ahead of the last release by ${ahead_by} + commit${ahead_by === 1 ? '' : 's'}. You may see documentation for features not yet supported in the latest release ${name}.

` From 7d1482929af1f3cbbf1b04aaa85169507083e4f9 Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Tue, 24 Dec 2024 20:53:18 +0000 Subject: [PATCH 2/5] fix link --- docs/_worker.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/_worker.js b/docs/_worker.js index 937e21f9e6..739758eb92 100644 --- a/docs/_worker.js +++ b/docs/_worker.js @@ -60,8 +60,10 @@ async function versionWarning(request, env) {

Version Notice

${env.CF_PAGES_BRANCH === 'main' ? '' : `(${env.CF_PAGES_BRANCH} preview)`} - This documentation is ahead of the last release by ${ahead_by} - commit${ahead_by === 1 ? '' : 's'}. + This documentation is ahead of the last release by + + ${ahead_by} commit${ahead_by === 1 ? '' : 's'} + . You may see documentation for features not yet supported in the latest release ${name}.

` From 7f213e39afc24a5c71b634bb3a77c700d27fb914 Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Tue, 24 Dec 2024 20:55:02 +0000 Subject: [PATCH 3/5] fix link url --- docs/_worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_worker.js b/docs/_worker.js index 739758eb92..594fd4a2fd 100644 --- a/docs/_worker.js +++ b/docs/_worker.js @@ -61,7 +61,7 @@ async function versionWarning(request, env) {

${env.CF_PAGES_BRANCH === 'main' ? '' : `(${env.CF_PAGES_BRANCH} preview)`} This documentation is ahead of the last release by - + ${ahead_by} commit${ahead_by === 1 ? '' : 's'} . You may see documentation for features not yet supported in the latest release ${name}. From b97f0ddd639879de699fe290402ecceee872967c Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Tue, 24 Dec 2024 20:57:39 +0000 Subject: [PATCH 4/5] fix whitespace --- docs/_worker.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/_worker.js b/docs/_worker.js index 594fd4a2fd..e848cd28dd 100644 --- a/docs/_worker.js +++ b/docs/_worker.js @@ -61,9 +61,7 @@ async function versionWarning(request, env) {

${env.CF_PAGES_BRANCH === 'main' ? '' : `(${env.CF_PAGES_BRANCH} preview)`} This documentation is ahead of the last release by - - ${ahead_by} commit${ahead_by === 1 ? '' : 's'} - . + ${ahead_by} commit${ahead_by === 1 ? '' : 's'}. You may see documentation for features not yet supported in the latest release ${name}.

` From 6dd3ed7bb5e4df2efb0ed8d4c806bdeaa26d7f37 Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Tue, 24 Dec 2024 21:00:04 +0000 Subject: [PATCH 5/5] use branch in diff url --- docs/_worker.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/_worker.js b/docs/_worker.js index e848cd28dd..1fd06049d0 100644 --- a/docs/_worker.js +++ b/docs/_worker.js @@ -46,8 +46,7 @@ async function versionWarning(request, env) { const text = await r2.text() throw new Error(`Failed to fetch compare, response status ${r2.status}:\n${text}`) } - const r2_data = await r2.json() - const {ahead_by} = r2_data + const {ahead_by} = await r2.json() if (ahead_by === 0) { return `
@@ -56,12 +55,14 @@ async function versionWarning(request, env) {
` } + const branch = env.CF_PAGES_BRANCH + const diff_html_url = `https://github.com/pydantic/pydantic-ai/compare/${tag_name}...${branch}` return `

Version Notice

- ${env.CF_PAGES_BRANCH === 'main' ? '' : `(${env.CF_PAGES_BRANCH} preview)`} + ${branch === 'main' ? '' : `(${branch} preview)`} This documentation is ahead of the last release by - ${ahead_by} commit${ahead_by === 1 ? '' : 's'}. + ${ahead_by} commit${ahead_by === 1 ? '' : 's'}. You may see documentation for features not yet supported in the latest release ${name}.

`