Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix links error when using GitHub Enterprise #2350

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/changelog-notes/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import {
BuildNotesOptions,
} from '../changelog-notes';
import {ConventionalCommit} from '../commit';
import { DEFAULT_GITHUB_SERVER_URL } from '../util/github-server';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const conventionalChangelogWriter = require('conventional-changelog-writer');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const presetFactory = require('conventional-changelog-conventionalcommits');
const DEFAULT_HOST = 'https://github.com';

interface DefaultChangelogNotesOptions {
commitPartial?: string;
Expand Down Expand Up @@ -53,7 +53,7 @@ export class DefaultChangelogNotes implements ChangelogNotes {
options: BuildNotesOptions
): Promise<string> {
const context = {
host: options.host || DEFAULT_HOST,
host: options.host || DEFAULT_GITHUB_SERVER_URL,
owner: options.owner,
repository: options.repository,
version: options.version,
Expand Down
3 changes: 2 additions & 1 deletion src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {Logger} from 'code-suggester/build/src/types';
import {HttpsProxyAgent} from 'https-proxy-agent';
import {HttpProxyAgent} from 'http-proxy-agent';
import {PullRequestOverflowHandler} from './util/pull-request-overflow-handler';
import {DEFAULT_GITHUB_SERVER_URL} from './util/github-server';

// Extract some types from the `request` package.
type RequestBuilderType = typeof request;
Expand Down Expand Up @@ -1430,7 +1431,7 @@ export class GitHub {
commentOnIssue = wrapAsync(
async (comment: string, number: number): Promise<string> => {
this.logger.debug(
`adding comment to https://github.com/${this.repository.owner}/${this.repository.repo}/issues/${number}`
`adding comment to ${DEFAULT_GITHUB_SERVER_URL}/${this.repository.owner}/${this.repository.repo}/issues/${number}`
);
const resp = await this.octokit.issues.createComment({
owner: this.repository.owner,
Expand Down
5 changes: 3 additions & 2 deletions src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {
} from './util/pull-request-overflow-handler';
import {signoffCommitMessage} from './util/signoff-commit-message';
import {CommitExclude} from './util/commit-exclude';
import {DEFAULT_GITHUB_SERVER_URL} from './util/github-server';

type ExtraGenericFile = {
type: 'generic';
Expand Down Expand Up @@ -1051,7 +1052,7 @@ export class Manifest {
// If unchanged, no need to push updates
if (existing.body === pullRequest.body.toString()) {
this.logger.info(
`PR https://github.com/${this.repository.owner}/${this.repository.repo}/pull/${existing.number} remained the same`
`PR ${DEFAULT_GITHUB_SERVER_URL}/${this.repository.owner}/${this.repository.repo}/pull/${existing.number} remained the same`
);
return undefined;
}
Expand All @@ -1076,7 +1077,7 @@ export class Manifest {
// If unchanged, no need to push updates
if (snoozed.body === pullRequest.body.toString()) {
this.logger.info(
`PR https://github.com/${this.repository.owner}/${this.repository.repo}/pull/${snoozed.number} remained the same`
`PR ${DEFAULT_GITHUB_SERVER_URL}/${this.repository.owner}/${this.repository.repo}/pull/${snoozed.number} remained the same`
);
return undefined;
}
Expand Down
1 change: 1 addition & 0 deletions src/util/github-server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const DEFAULT_GITHUB_SERVER_URL = process.env.GITHUB_SERVER_URL || 'https://github.com';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would like any environment variable handling to happen at the entrypoint of running release-please and injecting the configuration into the classes rather than pulling from the environment in various spots.

In this case, can we configure/pull this from the GitHub class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this should not happend in release-please but only in release-please-action while merging default...