Skip to content

introduced change that fixes issue #91#128

Open
jjijon7000 wants to merge 2 commits into
devfrom
issue-91-populate-version
Open

introduced change that fixes issue #91#128
jjijon7000 wants to merge 2 commits into
devfrom
issue-91-populate-version

Conversation

@jjijon7000

@jjijon7000 jjijon7000 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR automates populating the version field in code.json from the latest GitHub release while preserving the existing merge pattern in src/main.ts.

What changed

  • Removed existingCodeJSON from calculateMetaData() in src/helper.ts.
  • Kept release lookup logic in the helper, but now it only returns the latest release version string.
  • Moved the version fallback/merge logic into src/main.ts, following the same pattern already used for feedbackMechanism and SBOM.
  • Updated unit tests in:
    • src/__tests__/unit/helper.test.ts
    • src/__tests__/unit/main.test.ts

Notes

  • The implementation still uses the GitHub API release endpoint because repos.get() does not include latest release data.
  • If a release version cannot be fetched, main.ts preserves the existing version from code.json.

Validation

  • npx jest src/__tests__/unit/helper.test.ts src/__tests__/unit/main.test.ts

AI Usage

  • Generated AI was used in this contribution

If checked, please provide an explanation on how AI was used in the development of this pull request:

  • Description: Used ChatGPT (Codex) to refactor the PR to align with the existing project design patterns based on reviewer feedback.

  • Type of assistance:

  • Code generation

  • Documentation

  • Debugging

  • Testing

  • Refactoring

  • Other:

  • Scope of usage: src/main.ts, src/helper.ts, src/__tests__/unit/helper.test.ts, src/__tests__/unit/main.test.ts

  • AI System used:

  • ChatGPT

  • Claude

  • Gemini

  • GitHub Copilot

  • Level of modification: - [ ] As-is - [x] Modified - [ ] Used as inspiration

  • Prompts used: "Please refactor my code to address reviewer feedback on my PR... revert the function signature in helper.ts, move the merging logic to main.ts, and update the corresponding unit tests."

@jjijon7000 jjijon7000 added the enhancement New feature or request label Jul 14, 2026

@natalialuzuriaga natalialuzuriaga left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before approving, just wanted to ask about the current implementation choices and see whether other alternate approaches could be better suited. I also defer to Sachin though since he wrote the existing code!

Comment thread src/helper.ts Outdated
Comment on lines +16 to +18
async function calculateMetaData(
existingCodeJSON?: CodeJSON | null,
): Promise<Partial<CodeJSON>> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a big change to add existingCodeJSON as an argument to this core function and wondering if this is necessary to do? Based on reviewing the code, I see an existing pattern where merging content between existingCodeJSON and partialCodeJSON occurs in the main.ts (I'll point to it in the next comment). Also, the getBasicInfo() function does very similar functionality as getVersion()where it calls the GitHub API to fetch data about the repo and eventually merges this data with existingCodeJSON

Just wanted to flag and see if we can follow patterns laid out in the existing code for consistency and evaluate whether adding the existingCodeJSON argument is truly necessary

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i would agree here that we want to stick with our design patterns currently.

Comment thread src/main.ts Outdated
Comment on lines 96 to 106

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below shows the pattern of how we merge existingCodeJSON with partialCodeJSON. We can do the same here with version?

Comment thread src/helper.ts
Comment on lines 91 to 96
async function getBasicInfo(): Promise<BasicRepoInfo> {
try {
const [repoData, languagesData] = await Promise.all([
octokit.rest.repos.get({ owner, repo }),
octokit.rest.repos.listLanguages({ owner, repo }),
]);

@natalialuzuriaga natalialuzuriaga Jul 16, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Offering another implementation approach: we could instead add the version functionality to getBasicInfo() since it also uses octokit. Does octokit.rest.repos.get({owner, repo}) receive data on the repo's release tags? If so, could be worth just adding version into this function. If not, then a separate function makes sense

@natalialuzuriaga

natalialuzuriaga commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Last thing: as specified in our OSPO Gen AI Policy that was just shipped, please fill out this information about Gen AI usage and add this to your PR description:

AI Usage

  • Generated AI was used in this contribution

If checked, please provide an explanation on how AI was used in the development of this pull request:

  • Description: Include a high level description of Gen AI utilization
  • Type of assistance:
     - [ ] Code generation
     - [ ] Documentation
     - [ ] Debugging
     - [ ] Testing
     - [ ] Refactoring
     - [ ] Other:
  • Scope of usage: Which files, functions, or sections were AI-assisted
  • AI System used:
     - [ ] ChatGPT
     - [ ] Claude
     - [ ] Gemini
     - [ ] GitHub Copilot
  • Level of modification:
     - [ ] As-is
     - [ ] Modified
     - [ ] Used as inspiration
  • Prompts used: Please list or explain prompts that were used to develop this contribution

@sachin-panayil sachin-panayil left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the logic is great but following along with Natalias comment, we should stick with the design patterns unless truly necessary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants