Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
Merge pull request #27 from jabbera/logging-update1
Browse files Browse the repository at this point in the history
Update Logging
  • Loading branch information
jabbera authored Mar 28, 2018
2 parents 9ecced0 + 46afaed commit 9e7a629
Show file tree
Hide file tree
Showing 8 changed files with 2,599 additions and 1,189 deletions.
14 changes: 11 additions & 3 deletions Tasks/common/GitRefCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export abstract class GitRefCreator {
let authHandler = vsts.getPersonalAccessTokenHandler(token);
let connect = new vsts.WebApi(collectionUrl, authHandler);

let gitapi: git.IGitApi = connect.getGitApi();
let bldapi: bld.IBuildApi = connect.getBuildApi();
let gitapi: git.IGitApi = await connect.getGitApi();
let bldapi: bld.IBuildApi = await connect.getBuildApi();

let artifactData: IArtifactData[] = await this.getAllGitArtifacts(bldapi, gitapi);

Expand Down Expand Up @@ -227,18 +227,22 @@ export abstract class GitRefCreator {
}

protected async processArtifact(artifact: IArtifactData, gitapi: git.IGitApi) {
tl.debug(`Processing artifact: '${artifact.name}' for ref: ${this.refName} new commit: ${artifact.commit} old commit ${artifact.oldCommitId}`);
tl.debug(`Processing artifact: '${artifact.name}' for ref: ${this.refName} new commit: ${artifact.commit}`);

// Do this here instead of during population to avoid : https://github.com/jabbera/vsts-git-release-tag/issues/20
await this.populateExistingRefCommit(artifact, this.refName, gitapi);

tl.debug(`Old commit ${artifact.oldCommitId}`);

// See if there is a matching ref for the same commit. We won't overwrite an existing ref. Done after the update so all refs don't need to be brought back every time.
if (artifact.oldCommitId === artifact.commit) {
tl.debug("Found matching ref for commit.");
return true;
}

let localRefName: string = `refs/${this.refName}`;
tl.debug(`Updating ref: ${localRefName}`);

let updateResult: giti.GitRefUpdateResult = await this.updateRef(artifact, localRefName, gitapi);
if (updateResult.success) {
tl.debug("Ref updated!");
Expand All @@ -259,11 +263,15 @@ export abstract class GitRefCreator {
tl.setResult(tl.TaskResult.Failed, `Unable to create ref: ${this.refName} UpdateStatus: ${updateResult.updateStatus} RepositoryId: ${updateResult.repositoryId} Old Commit: ${updateResult.oldObjectId} New Commit: ${updateResult.newObjectId}`);
}
private async populateExistingRefCommit(artifact: IArtifactData, refName: string, gitapi: git.IGitApi) {
tl.debug(`Getting refs for: '${refName}' with repositoryId: '${artifact.repositoryId}'`);

let refs: giti.GitRef[] = await gitapi.getRefs(artifact.repositoryId, null, refName);
if (refs == null) {
tl.debug(`No refs returned`);
return;
}

tl.debug(`Got refs. Length = ${refs.length}`);
let foundRef: giti.GitRef = refs.find((x) => x.name.endsWith(refName));
if (foundRef == null) {
return;
Expand Down
102 changes: 102 additions & 0 deletions Tasks/git-branch-on-release-task/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Tasks/git-branch-on-release-task/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"author": "",
"license": "MIT",
"dependencies": {
"vso-node-api": "^6.2.8-preview",
"vsts-task-lib": "^2.1.0"
"vso-node-api": "^6.3.2",
"vsts-task-lib": "^2.3.0"
}
}
102 changes: 102 additions & 0 deletions Tasks/git-tag-on-release-task/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Tasks/git-tag-on-release-task/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"author": "",
"license": "MIT",
"dependencies": {
"vso-node-api": "^6.2.8-preview",
"vsts-task-lib": "^2.1.0"
"vso-node-api": "^6.3.2",
"vsts-task-lib": "^2.3.0"
}
}
Loading

0 comments on commit 9e7a629

Please sign in to comment.