Skip to content

Commit

Permalink
Fix builtin baseline get
Browse files Browse the repository at this point in the history
  • Loading branch information
jyu49 committed Aug 24, 2023
1 parent 8506815 commit dbf7420
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"icon": "images/vcpkg-logo.png",
"publisher": "JackBoosY",
"license": "MIT",
"version": "2.0.2",
"version": "2.0.3",
"engines": {
"vscode": "^1.76.0"
},
Expand Down
41 changes: 33 additions & 8 deletions src/versionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ export class VersionManager {
return new Array<{version: string, hash: string}>;
}

finalVersion += '#' + json.versions[i]["port-version"];
results.push({version: finalVersion, hash: json.versions[i]["git-tree"]});
const finalVersionWithPatch = finalVersion + '#' + json.versions[i]["port-version"];
results.push({version: finalVersionWithPatch, hash: this.getVersionDate(name, finalVersion)});
}

return results;
Expand Down Expand Up @@ -110,7 +110,7 @@ export class VersionManager {

if (!version.length)
{
return json.versions[0]["git-tree"];
return this.getVersionDate(name, json.versions[0]["version"]);
}

for (let i = 0; i < json.versions.length; i++)
Expand All @@ -136,19 +136,44 @@ export class VersionManager {
{
continue;
}
expectedVersion += '#' + json.versions[i]["port-version"];
if (expectedVersion === version)
const expectedVersionWithPatch = expectedVersion + '#' + json.versions[i]["port-version"];
if (expectedVersionWithPatch === version)
{
return json.versions[i]["git-tree"];
return this.getVersionDate(name, expectedVersion);
}
}

return "";
}

private getVersionDate(name: string, version: string, patch: string)
private getVersionDate(name: string, version: string)
{
const verionFile = this.getPortVersionFile(name);
const command = "git blame -l" + verionFile;
let command = "cd " + this._vcpkgRoot + "../;";
command += "git blame -l " + verionFile;
const cp = require('child_process');
let result = "";
try
{
result = cp.execSync(command).toString();
}
catch(e)
{
return "";
}

const results = result.split('\n');
let found = "";
for (let current of results)
{
if (current.search(version) !== -1)
{
found = current;
break;
}
}
found = found.substring(0, found.indexOf(' '));

return found;
}
}

0 comments on commit dbf7420

Please sign in to comment.