Skip to content

Commit 37a4262

Browse files
committed
Get commit from nuspec
1 parent d871bc7 commit 37a4262

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

tasks/createTagsTasks.ts

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as gulp from 'gulp';
7-
import * as xml2js from 'xml2js';
87
import * as fs from 'fs';
9-
import axios, { AxiosResponse } from 'axios';
108
import * as minimist from 'minimist';
119
import { Octokit } from '@octokit/rest';
1210

@@ -68,9 +66,23 @@ async function findRoslynCommitAsync(): Promise<string | null> {
6866

6967
console.log(`Roslyn version is ${roslynVersion}`);
7068
// Nuget package should exist under out/.nuget/ since we have run the install dependencies task.
71-
const nuspecFile = fs.readFileSync(`out/.nuget/microsoft.codeAnalysis.languageServer/${roslynVersion}`);
72-
const nuspecFileXml = await xml2js.parseStringPromise(nuspecFile);
73-
const commitNumber = nuspecFileXml.package.metadata[0].repository[0].$['commit'];
69+
const nuspecFile = fs
70+
.readFileSync(
71+
`out/.nuget/microsoft.codeAnalysis.languageServer/${roslynVersion}/microsoft.codeAnalysis.languageServer.nuspec`
72+
)
73+
.toString();
74+
const results = /commit="(.*)"/.exec(nuspecFile);
75+
if (results == null || results.length == 0) {
76+
logError('Failed to find commit number from nuspec file');
77+
return null;
78+
}
79+
80+
if (results.length != 2) {
81+
logError('Unexpected regex match result from nuspec file.');
82+
return null;
83+
}
84+
85+
const commitNumber = results[1];
7486
console.log(`commitNumber is ${commitNumber}`);
7587
return commitNumber;
7688
}
@@ -119,21 +131,6 @@ async function tagRepoAsync(
119131
return true;
120132
}
121133

122-
async function sendHttpsGetRequestAsync(url: string): Promise<AxiosResponse<any, any> | null> {
123-
try {
124-
const nuspecResponse = await axios.get(url);
125-
if (nuspecResponse.status != 200) {
126-
logError('Failed to get nuspec file from nuget server');
127-
return null;
128-
}
129-
return nuspecResponse;
130-
} catch (err) {
131-
logError(`Failed to get response for ${url}`);
132-
}
133-
134-
return null;
135-
}
136-
137134
function logError(message: string): void {
138135
console.log(`##vso[task.logissue type=error]${message}`);
139136
}

0 commit comments

Comments
 (0)