diff --git a/dist/index.js b/dist/index.js index 18443eb..82367ec 100644 --- a/dist/index.js +++ b/dist/index.js @@ -35913,7 +35913,6 @@ exports.run = void 0; const moment_1 = __importDefault(__nccwpck_require__(9623)); const githubRequests_1 = __nccwpck_require__(2963); const bash_1 = __nccwpck_require__(9134); -const github_1 = __nccwpck_require__(5438); async function run(path) { await (0, bash_1.exec)(`git -C ${path} fetch --depth=50 origin +refs/heads/*:refs/remotes/origin/*`); const commitHash = await (0, bash_1.exec)(`git -C ${path} rev-parse HEAD`); @@ -35923,7 +35922,6 @@ async function run(path) { const submoduleName = await (0, bash_1.exec)(`basename $(git -C ${path} rev-parse --show-toplevel)`); const lastCommit = await getLastCommit(path); const links = await getLinks(path, commitHash, branch); - console.log('Workflow', github_1.context.workflow); await comment(submoduleName, `**Submodule "${submoduleName}" status** - Current branch: **${branch}** @@ -35948,9 +35946,15 @@ async function getBehindTime(path, commitHash) { return timeDiff.humanize(); } async function getLastCommit(path) { - const lastCommitMessage = await (0, bash_1.exec)(`git -C ${path} log -1 --pretty=format:%s`); - const lastCommitAuthor = await (0, bash_1.exec)(`git -C ${path} log -1 --pretty=%an`); - return `"${lastCommitMessage.trim().substring(0, 50)}" by ${lastCommitAuthor.trim()}`; + const submodule = await (0, bash_1.exec)(`git -C ${path} remote get-url origin | sed -e 's/.*:\/\/github.com\///' -e 's/.*:\/\///' -e 's/\.git$//' + `); + const author = await (0, bash_1.exec)(`git -C ${path} log -1 --pretty=%an`); + const message = await (0, bash_1.exec)(`git -C ${path} log -1 --pretty=format:%s`); + const formattedMessage = message + .trim() + .substring(0, 50) + .replace('Merge pull request #', `Merge pull request ${submodule}#`); + return `"${formattedMessage.trim().substring(0, submodule.length + 50)}" by ${author.trim()}`; } async function getLinks(path, commitHash, branch) { const submoduleUrl = (await (0, bash_1.exec)(`git -C ${path} config --get remote.origin.url`)).replace('.git', ''); @@ -35964,7 +35968,6 @@ function getExactStateLink(submoduleUrl, commitHash) { } async function getSubmodulePullRequestLink(branch, submoduleUrl) { const pr = await getSubmodulePullRequestByBranchName(branch, submoduleUrl); - console.log('PR debug', pr, branch, submoduleUrl); return pr ? `[View ${pr.state} PR](${pr.html_url})` : ''; } async function getSubmodulePullRequestByBranchName(branchName, submoduleUrl) { diff --git a/package.json b/package.json index 4a5f89d..bfebee5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@remato/submodule-status-commenter", - "version": "1.0.0", + "version": "1.0.1", "license": "MIT", "description": "GitHub action to comment submodules current branch and state to the PR", "main": "dist/index.js", diff --git a/src/main.ts b/src/main.ts index 0023133..47ac7e9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,7 +6,6 @@ import { updatePullRequestComment, } from './githubRequests' import { exec } from './bash' -import { context } from '@actions/github' export async function run(path: string) { await exec(`git -C ${path} fetch --depth=50 origin +refs/heads/*:refs/remotes/origin/*`) @@ -19,8 +18,6 @@ export async function run(path: string) { const lastCommit = await getLastCommit(path) const links = await getLinks(path, commitHash, branch) - console.log('Workflow', context.workflow) - await comment( submoduleName, `**Submodule "${submoduleName}" status** @@ -54,10 +51,17 @@ async function getBehindTime(path: string, commitHash: string) { } async function getLastCommit(path: string) { - const lastCommitMessage = await exec(`git -C ${path} log -1 --pretty=format:%s`) - const lastCommitAuthor = await exec(`git -C ${path} log -1 --pretty=%an`) - - return `"${lastCommitMessage.trim().substring(0, 50)}" by ${lastCommitAuthor.trim()}` + const submodule = + await exec(`git -C ${path} remote get-url origin | sed -e 's/.*:\/\/github.com\///' -e 's/.*:\/\///' -e 's/\.git$//' + `) + const author = await exec(`git -C ${path} log -1 --pretty=%an`) + const message = await exec(`git -C ${path} log -1 --pretty=format:%s`) + const formattedMessage = message + .trim() + .substring(0, 50) + .replace('Merge pull request #', `Merge pull request ${submodule}#`) + + return `"${formattedMessage.trim().substring(0, submodule.length + 50)}" by ${author.trim()}` } async function getLinks(path: string, commitHash: string, branch: string) { @@ -77,8 +81,6 @@ function getExactStateLink(submoduleUrl: string, commitHash: string) { async function getSubmodulePullRequestLink(branch: string, submoduleUrl: string) { const pr = await getSubmodulePullRequestByBranchName(branch, submoduleUrl) - console.log('PR debug', pr, branch, submoduleUrl) - return pr ? `[View ${pr.state} PR](${pr.html_url})` : '' }