Skip to content

Commit

Permalink
added gha commit info
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelangarano committed Jan 22, 2024
1 parent dd41486 commit 8dc12a1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
2 changes: 2 additions & 0 deletions packages/cypress-cloud/lib/ciProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import debugFn from "debug";

import _ from "lodash";
import { ValidationError } from "./errors";
import { GhaEventData } from "./git";

const debug = debugFn("currents:ci");

Expand Down Expand Up @@ -650,6 +651,7 @@ type CiProviderData = {
defaultBranch?: string;
remoteBranch?: string;
runAttempt?: string;
ghaEventData?: GhaEventData;
};

interface ProviderCommitParamsRes {
Expand Down
31 changes: 22 additions & 9 deletions packages/cypress-cloud/lib/git.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
// @ts-ignore
import git from "@cypress/commit-info";
import { commitInfo } from "@currents/commit-info";
import { getCommitDefaults } from "./ciProvider";

export const getGitInfo = async (projectRoot: string) => {
const commitInfo = await git.commitInfo(projectRoot);
export type GhaEventData = {
headRef: string;
headSha: string;
baseRef: string;
baseSha: string;
issueUrl: string;
htmlUrl: string;
prTitle: string;
senderAvatarUrl: string;
senderHtmlUrl: string;
};

export const getGitInfo = async () => {
const commit = await commitInfo();
return getCommitDefaults({
branch: commitInfo.branch,
remoteOrigin: commitInfo.remote,
authorEmail: commitInfo.email,
authorName: commitInfo.author,
message: commitInfo.message,
sha: commitInfo.sha,
branch: commit.branch,
remoteOrigin: commit.remote,
authorEmail: commit.email,
authorName: commit.author,
message: commit.message,
sha: commit.sha,
ghaEventData: commit.ghaEventData,
});
};
2 changes: 1 addition & 1 deletion packages/cypress-cloud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"typescript": "^4.7.4"
},
"dependencies": {
"@cypress/commit-info": "^2.2.0",
"@cypress/commit-info": "1.0.1-beta.0",
"axios": "^1.2.0",
"axios-retry": "^3.4.0",
"bluebird": "^3.7.2",
Expand Down

0 comments on commit 8dc12a1

Please sign in to comment.