Skip to content

Conversation

@plon-Susk7
Copy link
Contributor

PR Checklist

  • The commit message follows our guidelines: Code of conduct
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Does this PR introduce a breaking change?
  • Include PR in release notes?

PR Type

  • Bugfix
  • Feature
  • Refactoring
  • Build /CI
  • Documentation
  • Others

What is the current behavior?

No patchflow to generate usage example.

Issue Number: #878

What is the new behavior?

This PR introduces a new patchflow that generates usage example when provided with folder_path as argument.

Other information

@CTY-git CTY-git self-requested a review December 11, 2024 02:09
Copy link
Contributor

@CTY-git CTY-git left a comment

Choose a reason for hiding this comment

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

Hi can you generate a usage example with the patchflow? Thanks.

@plon-Susk7
Copy link
Contributor Author

Hi can you generate a usage example with the patchflow? Thanks.

plon-Susk7#5
This was usage example for GenerateUnitTests patch

@CTY-git
Copy link
Contributor

CTY-git commented Dec 19, 2024

Hi can you generate a usage example with the patchflow? Thanks.

plon-Susk7#5 This was usage example for GenerateUnitTests patch

patchflows are meant to be run from the CLI, so this new GenerateUnitTests patchflow only generates example code usage?

@plon-Susk7
Copy link
Contributor Author

Hi can you generate a usage example with the patchflow? Thanks.

plon-Susk7#5 This was usage example for GenerateUnitTests patch

patchflows are meant to be run from the CLI, so this new GenerateUnitTests patchflow only generates example code usage?

yes

@CTY-git
Copy link
Contributor

CTY-git commented Dec 20, 2024

@plon-Susk7 can you try generating a example for a js file as well?

Also please change the patchflow name to GenerateCodeUsageExample instead.
In addition please fix the merge conflicts. Thank you.

@plon-Susk7
Copy link
Contributor Author

Here's example for js file
https://github.com/plon-Susk7/patchwork/pull/5/files

class VersionBumper {
    constructor(initialVersion = "0.1.0") {
      if (!this.isValidVersion(initialVersion)) {
        throw new Error("Invalid version format. Use Semantic Versioning (MAJOR.MINOR.PATCH).");
      }
      this.version = initialVersion;
    }
  
    /**
     * Validate the version string
     * @param {string} version
     * @returns {boolean}
     */
    isValidVersion(version) {
      return /^\d+\.\d+\.\d+$/.test(version);
    }
  
    /**
     * Get the current version
     * @returns {string}
     */
    getVersion() {
      return this.version;
    }
  
    /**
     * Bump the version based on the type
     * @param {string} type - "major", "minor", or "patch"
     * @returns {string} - New version
     */
    bump(type) {
      const [major, minor, patch] = this.version.split(".").map(Number);
  
      let newVersion;
      switch (type) {
        case "major":
          newVersion = `${major + 1}.0.0`;
          break;
        case "minor":
          newVersion = `${major}.${minor + 1}.0`;
          break;
        case "patch":
          newVersion = `${major}.${minor}.${patch + 1}`;
          break;
        default:
          throw new Error('Invalid bump type. Use "major", "minor", or "patch".');
      }
  
      this.version = newVersion;
      return this.version;
    }
  
    /**
     * Set the version explicitly
     * @param {string} version
     */
    setVersion(version) {
      if (!this.isValidVersion(version)) {
        throw new Error("Invalid version format. Use Semantic Versioning (MAJOR.MINOR.PATCH).");
      }
      this.version = version;
    }
  
    /**
     * Generate a tag for the version
     * @returns {string}
     */
    generateTag(prefix = "v") {
      return `${prefix}${this.version}`;
    }
  }
  
  export default VersionBumper;
  

@plon-Susk7
Copy link
Contributor Author

@plon-Susk7 can you try generating a example for a js file as well?

Also please change the patchflow name to GenerateCodeUsageExample instead. In addition please fix the merge conflicts. Thank you.

Done 👍

Copy link
Contributor

@CTY-git CTY-git left a comment

Choose a reason for hiding this comment

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

LGTM

@CTY-git CTY-git merged commit c0345eb into patched-codes:main Dec 23, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants