Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create getBranchNameFromRef utility function #24

Open
babblebey opened this issue Apr 3, 2024 · 2 comments
Open

Create getBranchNameFromRef utility function #24

babblebey opened this issue Apr 3, 2024 · 2 comments
Assignees
Labels
↘️ low priority This issue is nice to fix good first issue Good for newcomers

Comments

@babblebey
Copy link
Member

babblebey commented Apr 3, 2024

Create a utility function named getBranchNameFromRef that extracts the branch name from a branch reference string. This function should take a string parameter representing the branch reference and return the branch name. The function should perform the operation branchRef.split("/").slice(2).join("/") to extract the branch name.

Task

  1. Create a new utility function named getBranchNameFromRef in the src/lib/utils/index.js file.
  2. Implement the function to extract the branch name from the branch reference string.
  3. Integrate the getBranchNameFromRef function in the writeNewWord and editExistingWord functions in the word-editor script located in the src/lib directory. Replace the line const branch = repoBranchRef.split("/").slice(2).join("/"); in both functions with const branch = getBranchNameFromRef(repoBranchRef);.

Example

// Function implementation
function getBranchNameFromRef(branchRef) {
  return branchRef.split("/").slice(2).join("/");
}

// Usage example
const branchRef = "refs/heads/main";
const branchName = getBranchNameFromRef(branchRef);
console.log(branchName); // Output: "main"

Guidelines

  • Follow the existing code style and formatting conventions.
  • Add jsdoc please to aid auto-complete

Additional Information

  • Related Files:
    • src/lib/utils/index.js
    • src/lib/word-editor.js
  • Feel free to ask any questions away 😉
@babblebey babblebey added good first issue Good for newcomers ↘️ low priority This issue is nice to fix labels Apr 3, 2024
@Adebemdev
Copy link

I interested in contributing to this project and is there issue for me to contribute to ?

@babblebey
Copy link
Member Author

You can get started with this one @Adebemdev

Start by looking at the README and the Contributing Guide to help you set-up the project locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
↘️ low priority This issue is nice to fix good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants