message: Fix commits url for bitbucket server
diff: @@ -161,13 +161,18 @@ export class BitbucketUrlReader implements UrlReader {
  }
  private async getLastCommitShortHash(url: string): Promise<string> {
  - const { name: repoName, owner: project, ref } = parseGitUrl(url);
  + const { resource, name: repoName, owner: project, ref } = parseGitUrl(url);
  let branch = ref;
  if (!branch) {
  branch = await getBitbucketDefaultBranch(url, this.config);
  }
  - const commitsApiUrl = `${this.config.apiBaseUrl}/repositories/${project}/${repoName}/commits/${branch}`;
  +
  + const isHosted = resource === 'bitbucket.org';
  + // Bitbucket Server https://docs.atlassian.com/bitbucket-server/rest/7.9.0/bitbucket-rest.html#idp222
  + const commitsApiUrl = isHosted
  + ? `${this.config.apiBaseUrl}/repositories/${project}/${repoName}/commits/${branch}`
  + : `${this.config.apiBaseUrl}/projects/${project}/repos/${repoName}/commits`;
  const commitsResponse = await fetch(
  commitsApiUrl,
  @@ -182,6 +187,7 @@ export class BitbucketUrlReader implements UrlReader {
  }
  const commits = await commitsResponse.json();
  + if (isHosted) {
  if (
  commits &&
  commits.values &&
  @@ -190,6 +196,17 @@ export class BitbucketUrlReader implements UrlReader {
  ) {
  return commits.values[0].hash.substring(0, 12);
  }
  + } else {
  + if (
  + commits &&
  + commits.values &&
  + commits.values.length > 0 &&
  + commits.values[0].id
  + ) {
  + return commits.values[0].id.substring(0, 12);
  + }
  + }
  +
  throw new Error(`Failed to read response from ${commitsApiUrl}`);
  }
  }
  