-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
210 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
You are a GitHub Pull Request analyst. Your task is to create a concise, well-structured Markdown summary of a PR to help reviewers quickly understand the changes and their implications. | ||
|
||
You will be given JSON data about the PR, including commits, descriptions, and file changes. | ||
|
||
Analyze this data to extract key information for your summary, focusing on commit messages and significant code changes. | ||
|
||
Your output should be a Markdown document with the following structure: | ||
|
||
### Why: | ||
### What: | ||
### How can it be used: | ||
### How did you test it: | ||
### Notes for the reviewer: | ||
|
||
Guidelines for each section: | ||
|
||
1. **Why:** | ||
- Summarize the motivation for the change in 1-2 sentences. | ||
- Start with an action verb (e.g., Fixes, Enhances, Refactors). | ||
- Do not mention the project name or that this is a pull request. | ||
|
||
2. **What:** | ||
- List the main changes made, focusing on the most impactful ones. | ||
- Limit to 2-3 concise bullet points. | ||
|
||
3. **How can it be used:** | ||
- Briefly describe the effect of the changes. | ||
- Include short code snippets if relevant, enclosed in triple backticks ```. | ||
|
||
4. **How did you test it:** | ||
- Mention the testing methods used in 1-2 sentences. | ||
- Explain how these tests validate the changes. | ||
|
||
5. **Notes for the reviewer:** | ||
- Provide any additional important information in 1-2 sentences. | ||
- Highlight any areas needing special attention. | ||
|
||
Writing instructions: | ||
|
||
- Be direct and succinct. | ||
- Use an assertive tone without hedging language. | ||
- Maintain the specified section names and order. | ||
- Keep each section brief, with a maximum of 2-3 items or sentences. | ||
- Use code blocks only in "How can it be used" if necessary. | ||
|
||
Begin your response with "### Why:" and proceed through all sections in order. Your goal is to offer a clear, concise summary to assist the PR reviewer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# name: OpenAI PR Description Generator | ||
|
||
# on: | ||
# pull_request: | ||
# types: | ||
# - opened | ||
# - synchronize | ||
|
||
# permissions: | ||
# pull-requests: write | ||
# contents: read | ||
|
||
# jobs: | ||
# pull-request: | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - uses: actions/checkout@v3 | ||
# - name: Generate PR Description | ||
# uses: Ant0wan/openai-pr@v1 | ||
# with: | ||
# api-key: ${{ secrets.OPENAI_API_KEY }} | ||
# model: "gpt-4o-mini" | ||
# template-filepath: ".github/PR_TEMPLATE.md" | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,97 @@ | ||
"use strict"; | ||
|
||
/** | ||
* Project: swiss-ssn | ||
* Purpose: Validate and generate Swiss SSN's according to http://www.sozialversicherungsnummer.ch/aufbau-neu.htm | ||
* Author: teaddict | ||
* @version 1.0.2 | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
class SwissSSN { | ||
static #COUNTRY_CODE = [7, 5, 6]; | ||
static #MAX_VALUE = 10; | ||
static #SSN_LENGTH = 13; | ||
(function (global, factory) { | ||
if (typeof define === "function" && define.amd) { | ||
define(["exports"], factory); | ||
} else if (typeof exports !== "undefined") { | ||
factory(exports); | ||
} else { | ||
var mod = { | ||
exports: {} | ||
}; | ||
factory(mod.exports); | ||
global.swissSsn = mod.exports; | ||
} | ||
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { | ||
"use strict"; | ||
|
||
/** | ||
* Validates parameter given SSN. Returns true if SSN is valid, otherwise false. | ||
* @param {string} ssn - For example '756.9217.0769.85' or '7569217076985' | ||
* @returns {boolean} | ||
* Project: swiss-ssn | ||
* Purpose: Validate and generate Swiss SSN's according to http://www.sozialversicherungsnummer.ch/aufbau-neu.htm | ||
* Author: teaddict | ||
* @version 1.0.2 | ||
*/ | ||
static validateSSN(ssn) { | ||
if (!ssn) { | ||
return false; | ||
Object.defineProperty(_exports, "__esModule", { | ||
value: true | ||
}); | ||
_exports.default = void 0; | ||
class SwissSSN { | ||
static #COUNTRY_CODE = [7, 5, 6]; | ||
static #MAX_VALUE = 10; | ||
static #SSN_LENGTH = 13; | ||
|
||
/** | ||
* Validates parameter given SSN. Returns true if SSN is valid, otherwise false. | ||
* @param {string} ssn - For example '756.9217.0769.85' or '7569217076985' | ||
* @returns {boolean} | ||
*/ | ||
static validateSSN(ssn) { | ||
if (!ssn) { | ||
return false; | ||
} | ||
const parsedSSN = this.#parse(ssn); | ||
if (parsedSSN.length !== this.#SSN_LENGTH) { | ||
return false; | ||
} | ||
const checkDigit = this.#getCheckDigit(parsedSSN); | ||
return parseInt(parsedSSN[12], 10) === checkDigit; | ||
} | ||
const parsedSSN = this.#parse(ssn); | ||
if (parsedSSN.length !== this.#SSN_LENGTH) { | ||
return false; | ||
|
||
/** | ||
* Creates a valid SSN using random numbers. | ||
* @returns {string} - valid ssn. | ||
*/ | ||
static generateSSN() { | ||
const randomNumbers = Array.from({ | ||
length: 9 | ||
}, () => Math.floor(Math.random() * this.#MAX_VALUE)); | ||
const ssnWithoutCheckDigit = [...this.#COUNTRY_CODE, ...randomNumbers]; | ||
const checkDigit = this.#getCheckDigit(ssnWithoutCheckDigit); | ||
const unformattedSSN = [...ssnWithoutCheckDigit, checkDigit]; | ||
return this.#ssnFormatter(unformattedSSN); | ||
} | ||
const checkDigit = this.#getCheckDigit(parsedSSN); | ||
return parseInt(parsedSSN[12], 10) === checkDigit; | ||
} | ||
|
||
/** | ||
* Creates a valid SSN using random numbers. | ||
* @returns {string} - valid ssn. | ||
*/ | ||
static generateSSN() { | ||
const randomNumbers = Array.from({ | ||
length: 9 | ||
}, () => Math.floor(Math.random() * this.#MAX_VALUE)); | ||
const ssnWithoutCheckDigit = [...this.#COUNTRY_CODE, ...randomNumbers]; | ||
const checkDigit = this.#getCheckDigit(ssnWithoutCheckDigit); | ||
const unformattedSSN = [...ssnWithoutCheckDigit, checkDigit]; | ||
return this.#ssnFormatter(unformattedSSN); | ||
} | ||
/** | ||
* Calculate check digit for SSN | ||
* @private | ||
*/ | ||
static #getCheckDigit(ssn) { | ||
const total = [...ssn].slice(0, 12).reduce((sum, digit, index) => { | ||
const multiplier = index % 2 === 0 ? 1 : 3; | ||
return sum + parseInt(digit, 10) * multiplier; | ||
}, 0); | ||
return total % 10 === 0 ? 0 : Math.ceil(total / 10) * 10 - total; | ||
} | ||
|
||
/** | ||
* Calculate check digit for SSN | ||
* @private | ||
*/ | ||
static #getCheckDigit(ssn) { | ||
const total = [...ssn].slice(0, 12).reduce((sum, digit, index) => { | ||
const multiplier = index % 2 === 0 ? 1 : 3; | ||
return sum + parseInt(digit, 10) * multiplier; | ||
}, 0); | ||
return total % 10 === 0 ? 0 : Math.ceil(total / 10) * 10 - total; | ||
} | ||
/** | ||
* Format SSN with dots | ||
* @private | ||
*/ | ||
static #ssnFormatter(ssn) { | ||
const ssnString = ssn.map(String); | ||
return `756.${ssnString.slice(3, 7).join("")}.${ssnString.slice(7, 11).join("")}.${ssnString.slice(11, 13).join("")}`; | ||
} | ||
|
||
/** | ||
* Format SSN with dots | ||
* @private | ||
*/ | ||
static #ssnFormatter(ssn) { | ||
const ssnString = ssn.map(String); | ||
return `756.${ssnString.slice(3, 7).join('')}.${ssnString.slice(7, 11).join('')}.${ssnString.slice(11, 13).join('')}`; | ||
/** | ||
* Parse SSN string by removing all non-digit characters | ||
* @private | ||
*/ | ||
static #parse(ssn) { | ||
return ssn.replace(/\D/g, ""); | ||
} | ||
} | ||
|
||
/** | ||
* Parse SSN string by removing all non-digit characters | ||
* @private | ||
*/ | ||
static #parse(ssn) { | ||
return ssn.replace(/\D/g, ''); | ||
// Export for different environments | ||
if (typeof window !== 'undefined') { | ||
window.SwissSSN = SwissSSN; // Browser global | ||
} | ||
} | ||
exports.default = SwissSSN; | ||
module.exports = exports.default; | ||
var _default = _exports.default = SwissSSN; | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters