Skip to content

Commit

Permalink
docs: pull latest version from tags instead of releases in docs page (#…
Browse files Browse the repository at this point in the history
…6487)

Fixes 6485

The releases only go back to `v1.6.0` since the team isn't releasing standalone binaries on GitHub releases.
  • Loading branch information
karolzwolak authored Feb 26, 2025
1 parent 328f453 commit 96264d2
Showing 1 changed file with 19 additions and 29 deletions.
48 changes: 19 additions & 29 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
</div>
<script>
const RustfmtTagsUrl = 'https://api.github.com/repos/rust-lang/rustfmt/tags';
const RustfmtLatestUrl = 'https://api.github.com/repos/rust-lang/rustfmt/releases/latest';
const UrlHash = window.location.hash.replace(/^#/, '');
const queryParams = new URLSearchParams(window.location.search);
const searchParam = queryParams.get('search');
Expand All @@ -134,18 +133,25 @@
scrolledOnce: false,
},
asyncComputed: {
async updateVersion() {
let latest;
try {
latest = (await axios.get(RustfmtLatestUrl)).data;
} catch(err) {
console.log(err);
return;
}
if (versionParam == null) {
this.viewVersion = latest.name;
}
},
async pullTags() {
let tags;
try {
tags = (await axios.get(RustfmtTagsUrl)).data;
} catch(e) {
this.handleReqFailure(e);
return;
}

const excludedTagVersions = new Set(['v0.7', 'v0.8.1']);

const tagOptions = tags
.map(tag => tag.name)
.filter(tag => tag.startsWith('v') && !excludedTagVersions.has(tag));

const latestRelease = tagOptions.find(tag => !tag.includes('rc'));
this.viewVersion = latestRelease;
this.versionOptions = this.versionOptions.concat(tagOptions);
},
async outputHtml() {
if (this.viewVersion !== this.oldViewVersion) {
const ConfigurationMdUrl =
Expand Down Expand Up @@ -207,22 +213,6 @@
});
}
},
created: async function() {
let tags;
try {
tags = (await axios.get(RustfmtTagsUrl)).data;
} catch(e) {
this.handleReqFailure(e);
return;
}

const excludedTagVersions = new Set(['v0.7', 'v0.8.1']);

const tagOptions = tags
.map(tag => tag.name)
.filter(tag => tag.startsWith('v') && !excludedTagVersions.has(tag));
this.versionOptions = this.versionOptions.concat(tagOptions);
},
updated() {
if (UrlHash === '') return;
this.$nextTick(() => {
Expand Down

0 comments on commit 96264d2

Please sign in to comment.