jargons.dev
jargons.dev copied to clipboard
Create `getBranchNameFromRef` utility function
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
- Create a new utility function named
getBranchNameFromRefin thesrc/lib/utils/index.jsfile. - Implement the function to extract the branch name from the branch reference string.
- Integrate the
getBranchNameFromReffunction in thewriteNewWordandeditExistingWordfunctions in theword-editorscript located in thesrc/libdirectory. Replace the lineconst branch = repoBranchRef.split("/").slice(2).join("/");in both functions withconst 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
jsdocplease to aid auto-complete
Additional Information
- Related Files:
src/lib/utils/index.jssrc/lib/word-editor.js
- Feel free to ask any questions away 😉
I interested in contributing to this project and is there issue for me to contribute to ?
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.
can i work on this?
Hey @chiomalovet,
Sorry, the issue is already assigned to someone else, you can ask to work on other issue that isn't assigned.
I would like to work on that because no one seems to be assigned. Could you please assign this issue to me?