compare to last commit in a PR when using git commands

This commit is contained in:
mirpedrol 2023-11-17 12:44:50 +01:00
parent 4067d88573
commit a1714efe8d
No known key found for this signature in database
GPG Key ID: B3E684FA07D3BB5D
3 changed files with 33 additions and 13 deletions

View File

@ -462,6 +462,26 @@ jobs:
</details>
<details>
<summary>Using git commands to detect changes</summary>
```yaml
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2 # To retrieve the preceding commit.
- uses: dorny/paths-filter@v2
id: filter
with:
filters: .github/filters.yaml
token: '' # Use git commands
```
</details>
### Custom processing of changed files
<details>

24
dist/index.js vendored
View File

@ -317,7 +317,7 @@ async function getCurrentRef() {
if (describe.exitCode === 0) {
return describe.stdout.trim();
}
return (await exec_1.getExecOutput('git', ['rev-parse', exports.HEAD])).stdout.trim();
return (await exec_1.getExecOutput('git', ['rev-parse', `${exports.HEAD}^2`])).stdout.trim();
}
finally {
core.endGroup();
@ -1284,8 +1284,8 @@ class OidcClient {
const res = yield httpclient
.getJson(id_token_url)
.catch(error => {
throw new Error(`Failed to get ID Token. \n
Error Code : ${error.statusCode}\n
throw new Error(`Failed to get ID Token. \n
Error Code : ${error.statusCode}\n
Error Message: ${error.result.message}`);
});
const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
@ -38003,7 +38003,7 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"]
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/
/******/ // The require function
/******/ function __nccwpck_require__(moduleId) {
/******/ // Check if module is in cache
@ -38017,7 +38017,7 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"]
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/
/******/ // Execute the module function
/******/ var threw = true;
/******/ try {
@ -38026,23 +38026,23 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"]
/******/ } finally {
/******/ if(threw) delete __webpack_module_cache__[moduleId];
/******/ }
/******/
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat */
/******/
/******/
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
/******/
/******/
/************************************************************************/
/******/
/******/
/******/ // startup
/******/ // Load entry module and return exports
/******/ // This entry module is referenced by other modules so it can't be inlined
/******/ var __webpack_exports__ = __nccwpck_require__(3109);
/******/ module.exports = __webpack_exports__;
/******/
/******/
/******/ })()
;
;

View File

@ -176,7 +176,7 @@ export async function getCurrentRef(): Promise<string> {
return describe.stdout.trim()
}
return (await getExecOutput('git', ['rev-parse', HEAD])).stdout.trim()
return (await getExecOutput('git', ['rev-parse', `${HEAD}^2`])).stdout.trim()
} finally {
core.endGroup()
}