Skip to content

Commit 96264d2

Browse files
authored
docs: pull latest version from tags instead of releases in docs page (#6487)
Fixes 6485 The releases only go back to `v1.6.0` since the team isn't releasing standalone binaries on GitHub releases.
1 parent 328f453 commit 96264d2

File tree

1 file changed

+19
-29
lines changed

1 file changed

+19
-29
lines changed

docs/index.html

+19-29
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@
108108
</div>
109109
<script>
110110
const RustfmtTagsUrl = 'https://api.github.com/repos/rust-lang/rustfmt/tags';
111-
const RustfmtLatestUrl = 'https://api.github.com/repos/rust-lang/rustfmt/releases/latest';
112111
const UrlHash = window.location.hash.replace(/^#/, '');
113112
const queryParams = new URLSearchParams(window.location.search);
114113
const searchParam = queryParams.get('search');
@@ -134,18 +133,25 @@
134133
scrolledOnce: false,
135134
},
136135
asyncComputed: {
137-
async updateVersion() {
138-
let latest;
139-
try {
140-
latest = (await axios.get(RustfmtLatestUrl)).data;
141-
} catch(err) {
142-
console.log(err);
143-
return;
144-
}
145-
if (versionParam == null) {
146-
this.viewVersion = latest.name;
147-
}
148-
},
136+
async pullTags() {
137+
let tags;
138+
try {
139+
tags = (await axios.get(RustfmtTagsUrl)).data;
140+
} catch(e) {
141+
this.handleReqFailure(e);
142+
return;
143+
}
144+
145+
const excludedTagVersions = new Set(['v0.7', 'v0.8.1']);
146+
147+
const tagOptions = tags
148+
.map(tag => tag.name)
149+
.filter(tag => tag.startsWith('v') && !excludedTagVersions.has(tag));
150+
151+
const latestRelease = tagOptions.find(tag => !tag.includes('rc'));
152+
this.viewVersion = latestRelease;
153+
this.versionOptions = this.versionOptions.concat(tagOptions);
154+
},
149155
async outputHtml() {
150156
if (this.viewVersion !== this.oldViewVersion) {
151157
const ConfigurationMdUrl =
@@ -207,22 +213,6 @@
207213
});
208214
}
209215
},
210-
created: async function() {
211-
let tags;
212-
try {
213-
tags = (await axios.get(RustfmtTagsUrl)).data;
214-
} catch(e) {
215-
this.handleReqFailure(e);
216-
return;
217-
}
218-
219-
const excludedTagVersions = new Set(['v0.7', 'v0.8.1']);
220-
221-
const tagOptions = tags
222-
.map(tag => tag.name)
223-
.filter(tag => tag.startsWith('v') && !excludedTagVersions.has(tag));
224-
this.versionOptions = this.versionOptions.concat(tagOptions);
225-
},
226216
updated() {
227217
if (UrlHash === '') return;
228218
this.$nextTick(() => {

0 commit comments

Comments
 (0)