feat(pull_request): add shortcut link on push of new branches@@ -1,5 +1,5 @@
{
- "_generatedAtUnix": 1665168785986,
+ "_generatedAtUnix": 1665170537064,
"_hashAlgorithm": "sha1",
"_version": 2,
"islands": {
@@ -58,7 +58,7 @@
"pathSourceMap": "./public/.islands/RepositoryInitialSetup.bundle.js.map"
},
"RepositoryPullRequestCreateForm": {
- "hash": "e83dae6dd37566500d8c76f6bebf9203863b75bf",
+ "hash": "74829146dd82b6f06c73911c9e1b02673b7a4a0f",
"pathSource": "./app/islands/RepositoryPullRequestCreateForm.tsx",
"pathBundle": "./public/.islands/RepositoryPullRequestCreateForm.bundle.js",
"pathSourceMap": "./public/.islands/RepositoryPullRequestCreateForm.bundle.js.map"
@@ -19,6 +19,8 @@ const getRepositoryPullRequestCreateView: ReqHandler = async (
request,
reply
) => {
+ const { from_branch } =
+ request.query as AppRoutesParams[AppRoute.REPOSITORY_PULL_REQUEST_CREATE]["querystring"];
const { orgSlug, repoSlug } =
request.params as AppRoutesParams[AppRoute.REPOSITORY_PULL_REQUEST_CREATE]["params"];
@@ -43,7 +45,14 @@ const getRepositoryPullRequestCreateView: ReqHandler = async (
repo,
isFork: repo.forkedFromRepoId != null,
},
- initialTarget: undefined,
+ initialTarget:
+ from_branch != null
+ ? {
+ parentOrg,
+ repo,
+ branch: from_branch,
+ }
+ : undefined,
},
};
@@ -19,6 +19,11 @@ export interface RepositoryPullRequestCreateFormPropsCommon {
errorMessage?: string | null;
}
+export interface RepositoryPullRequestTarget {
+ parentOrg: Organization;
+ repo: Repository;
+ branch: string;
+}
export type RepositoryPullRequestCreateFormPropsByState<
S extends PullRequestFormState = PullRequestFormState
> = S extends PullRequestFormState.CONFIGURE
@@ -30,23 +35,12 @@ export type RepositoryPullRequestCreateFormPropsByState<
isFork: boolean;
forkedFromRepoMetas?: RepositoryForkedFromRepoMeta;
};
- initialTarget?: {
- parentOrg: Organization;
- repo: Repository;
- };
+ initialTarget?: RepositoryPullRequestTarget;
}
: S extends PullRequestFormState.COMPARE
? {
- source: {
- parentOrg: Organization;
- repo: Repository;
- branch: string;
- };
- target: {
- parentOrg: Organization;
- repo: Repository;
- branch: string;
- };
+ source: RepositoryPullRequestTarget;
+ target: RepositoryPullRequestTarget;
}
: S extends PullRequestFormState.DETAILS
? {
@@ -152,6 +152,9 @@ export interface AppRoutesParams extends IRouteParams {
orgSlug: string;
repoSlug: string;
};
+ querystring: {
+ from_branch?: string;
+ };
};
[AppRoute.REPOSITORY_PULL_REQUEST_CREATE_ACTION]: {
params: {
@@ -472,6 +475,16 @@ export const AppRoutesSchemas: Record<AppRoute, undefined | FastifySchema> = {
},
},
},
+ querystring: {
+ type: "object",
+ required: [],
+ additionalProperties: false,
+ properties: {
+ from_branch: {
+ type: "string",
+ },
+ },
+ },
},
[AppRoute.REPOSITORY_PULL_REQUEST_CREATE_ACTION]: {
params: {
@@ -2,6 +2,7 @@
import type { ServiceMethodFactory } from "@ethicdevs/react-monolith";
import { GitServer } from "@ethicdevs/fastify-git-server";
// app
+import { Const } from "../../const";
import { Env } from "../../env";
import { GitServerServiceDeps } from "./types";
import { getEnv } from "../../utils/server";
@@ -13,11 +14,11 @@ const makeOnPushEvent: ServiceMethodFactory<
> = ({ request }) => {
const env = getEnv();
return ({ data, message }) => {
- message.write("\n");
if (data.packType === GitServer.PackType.RECEIVE) {
// client has done something like "git push" it is uploading
// server is receiving
console.log("receive-pack");
+ message.write("\n");
const [orgSlug, repoSlug] = data.repoSlug.split("/");
request.prisma.repository
@@ -54,8 +55,16 @@ const makeOnPushEvent: ServiceMethodFactory<
`Hey ${data.username}, welcome back 🖖. See the details of your push at:\n`
);
if (data.payload.refType === "head") {
- console.log("refName:", data.payload.refName);
message.write(`🔗 ${repoUrlBase}/show/${data.payload.commitId}\n`);
+ if (data.payload.refName !== Const.PRIMARY_BRANCH_REF) {
+ message.write(`\n`);
+ message.write(
+ `🚀 Quickly create a pull-request from this branch at:\n`
+ );
+ message.write(
+ `🔗 ${repoUrlBase}/pulls/new?from_branch=${data.payload.refName}\n`
+ );
+ }
} else if (data.payload.refType === "tag") {
message.write(`🏷 ${repoUrlBase}/tags/${data.payload.refName}\n`);
}
@@ -66,6 +75,7 @@ const makeOnPushEvent: ServiceMethodFactory<
// client has done something like "git clone" or "git fetch" or "git pull",
// it is receiving, server is uploading
console.log("upload-pack");
+ // ⬇️ disabled because it seem to cause issues on git pull. ⬇️
// message.write(`🖖 Welcome at GitFOSS ${data.username}!\n`);
}