{"id":15605694,"url":"https://github.com/gangelo/branch-name","last_synced_at":"2025-04-26T23:25:21.578Z","repository":{"id":59544069,"uuid":"536910764","full_name":"gangelo/branch-name","owner":"gangelo","description":"branch-name is a gem that provides a command-line interface that allows you to accomplish several tasks, tasks I personally find myself having to carry out every time I work on a feature branch. I created this gem for myself; however, you are free to use it yourself, if any of these tasks fits into your personal routine: 1) Formulate a git feature branch name, given a jira ticket and jira ticket description. Why? Because I am constantly having to create git feature branch names that are based on jira ticket and jira ticket descriptions. 2) Optionally create a \"project\" based on the branch name (formulated in step 1 above). Why? Because I'm constantly having to create folders to manage files associated with the feature branches I am working on. 3) Optionally use and manage default options that determine the git feature branch name formulated, project greated, and default files associated with the project.Why? Because I routinely have to create files to support the feature I am working on and associate them with the feature I am working on. For example: scratch.rb to hold scratch code, snippets.rb to hold code to execute to perform redundant tasks, and readme.txt files to document things I need to remember.","archived":false,"fork":false,"pushed_at":"2025-02-06T21:15:19.000Z","size":140,"stargazers_count":6,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-25T19:09:42.030Z","etag":null,"topics":["agile","branch-names","cli","cli-app","productivity","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gangelo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-15T07:23:02.000Z","updated_at":"2025-02-06T21:15:23.000Z","dependencies_parsed_at":"2024-01-07T18:29:12.154Z","dependency_job_id":"07c33be9-3b6e-47b8-8db6-4fc8b50793d1","html_url":"https://github.com/gangelo/branch-name","commit_stats":{"total_commits":45,"total_committers":1,"mean_commits":45.0,"dds":0.0,"last_synced_commit":"453a664997de72adf75f6e5846ac972277c1a521"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gangelo%2Fbranch-name","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gangelo%2Fbranch-name/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gangelo%2Fbranch-name/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gangelo%2Fbranch-name/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gangelo","download_url":"https://codeload.github.com/gangelo/branch-name/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250878892,"owners_count":21501743,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agile","branch-names","cli","cli-app","productivity","ruby"],"created_at":"2024-10-03T04:11:31.746Z","updated_at":"2025-04-25T19:09:50.924Z","avatar_url":"https://github.com/gangelo.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `branch-name`\n\n[![Ruby](https://github.com/gangelo/branch-name/actions/workflows/ruby.yml/badge.svg?refresh=4.0.4)](https://github.com/gangelo/branch-name/actions/workflows/ruby.yml)\n[![GitHub version](http://badge.fury.io/gh/gangelo%2Fbranch-name.svg?refresh=4.0.4)](https://badge.fury.io/gh/gangelo%2Fbranch-name)\n[![Gem Version](https://badge.fury.io/rb/branch-name.svg?refresh=4.0.4)](https://badge.fury.io/rb/branch-name)\n[![](http://ruby-gem-downloads-badge.herokuapp.com/branch-name?type=total)](http://www.rubydoc.info/gems/branch-name/)\n[![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/branch-name/)\n[![Report Issues](https://img.shields.io/badge/report-issues-red.svg)](https://github.com/gangelo/branch-name/issues)\n[![License](http://img.shields.io/badge/license-MIT-yellowgreen.svg)](#license)\n\n`branch-name` is a gem that provides a command-line interface that allows you to accomplish several tasks, tasks I *personally* find myself having to carry out every time I work on a feature branch. I created this gem *for myself*; however, you are free to use it yourself, if any of these tasks fits into your personal routine:\n\n1. Formulate a git *feature branch name*, given a [jira](https://www.atlassian.com/software/jira) ticket and jira ticket description. **Why? Because I am constantly having to create git feature branch names that are based on jira ticket and jira ticket descriptions.**\n2. Optionally create a \"project\" based on the *branch name* (formulated in step 1 above). **Why? Because I'm constantly having to create folders to manage files associated with the feature branches I am working on.**\n3. Optionally use and manage default options that determine the git  feature branch name formulated, project greated, and default files associated with the project.**Why? Because I routinely have to create files to support the feature I am working on and associate them _with_ the feature I am working on. For example: scratch.rb to hold scratch code, snippets.rb to hold code to execute to perform redundant tasks, and readme.txt files to document things I need to remember.**\n\n## Caveats\n\nNOTE: This documentation assumes *macOS* and any reference to `\u003cusername\u003e` should be assumed to equal `$ whoami` unless otherwise noted.\n\nNOTE: This documentation makes reference to *cards* and/or *tickets*; these terms should be considered synonymous, and are used to refer to *user stories*, *tasks*, *bugs*, etc.; that is, work that is normally created against a software development team's [Jira](https://www.atlassian.com/software/jira) Project board while adhering to [Agile development methodology](https://www.atlassian.com/agile#:~:text=Agile%20is%20an%20iterative%20approach,small%2C%20but%20consumable%2C%20increments.). While `branch-name` was created to be used while practicing Agile, `branch-name` can be used outside the Agile context as well.\n\n\n## Installation\n\n    $ gem install branch-name\n\n## Usage/Examples\n\n### `branch-name` Help\n```shell\n# Display general branch-name help\n$ branch-name help\n\n# Display help for the 'create' command\n$ branch-name help create\n\n# Display help for the 'config' command and subsommands\n$ branch-name help config\n$ branch-name config help info\n$ branch-name config help init\n$ branch-name config help delete\n```\n\n### Initialize `branch-name` Configuration Files\nSetting up *global* settings would be a good place to start:\n\n```\n$ branch-name config init global\n#=\u003e Configuration file (/Users/\u003cusername\u003e/.branch-name) created\n```\n\nThis creates a `.branch-name` yaml configuration file the home folder of the current user (`$ whoami` on *macOS*) with the below option defaults. The option defaults created will be used with their respective `branch-name` command indicated by the `branch-name` command name under which each option resides. You may manually alter any of the option values to suite your needs. To determine what options are available for each `branch-name` command, simply view help for that particular command. If a `branch-name` command is *not* found in the `.branch-name` config file when it is first initialized (e.g. `$ branch-name config init global #=\u003e /Users/\u003cusername\u003e/.branch-name`), default options for that particular `branch-name` command are not currently supported.\n\nBelow is a list of _default_ options created when initializing _global_ options; consequently, these default options will be used whenever the `branch-name create` command is executed for the user \"`\u003cusername\u003e`\":\n\n```yaml\n# /Users/\u003cusername\u003e/.branch-name\n---\ncreate:\n  downcase: false\n  separator: _\n  format_string: \"%t %d\"\n  project: false\n  project_location: \"/Users/\u003cusername\u003e/branch-name/projects/%Y/%m (%B)\"\n  project_files:\n  - readme.txt\n  - scratch.rb\n  - snippets.rb\n  interactive: true\n  ```\n\nNOTE: You can manually change any of the options you wish. It is recommended that you change the default `create: project_location` to meet your needs, depending on your *os*. For example, on *macOS* you might want to change this to `\"/Users/\u003cusername\u003e/Documents\"`, `\"/Users/\u003cusername\u003e/Documents/features\"`, or something similar.\n\nThe `create: project_location` option string also accepts any [`Time.strftime`](`https://apidock.com/ruby/Time/strftime`) format directives.\n\nThe `create: format_string` option string can be used to position the *ticket* (`%t`) and *ticket description* (`%d`) within the branch name formulated. You can also include any other information you wish in the format string, for example: \"`\u003cusername\u003e %t %d`\". However, particular characters will be stripped to formulate the branch name (see `Branch::Name::Normalizable::BRANCH_NAME_REGEX` which equates to `%r{[^/\\w\\x20]|_}`).\n\nAny or all of these options can also be overwritten on the command-line. For more information:\n`$ branch-name config help init`\n\n### Creating Feature Branch Names and Projects Examples\n\nNOTE: `branch-name create` really doesn't \"create\" anything (unless you use the `-p` option, in which case it will create a \"project\" for you); rather, `branch-name create` simply _formulates_ a suitable feature branch name given a *jira* ticket and *jira* ticket description.\n\nNOTE: The below examples will assume the following `global` config file defaults (`$ branch-name config init global`) that have been *manually* manipulated to have the following options:\n\n```yaml\n# /Users/\u003cusername\u003e/.branch-name\n---\ncreate:\n  downcase: false\n  separator: _\n  format_string: \"%t %d\"\n  project: false\n  project_location: \"/Users/\u003cusername\u003e/feature-branches/%Y\"\n  project_files:\n  - readme.txt\n  - scratch.rb\n  - snippets.rb\n  interactive: true\n  ```\n\nThis example formulates feature a branch named *lg-12345-pay-down-tech-debt-on-user-model* by converting the ticket and ticket description to lowercase (`-d`) and delimiting the feature branch name tokens with a \"-\" character (`-s -`). The `-p` option instructs `branch-name create` to create the project folder */Users/\u003cusername\u003e/feature-branches/2022/lg-12345-pay-down-tech-debt-on-user-model*, and finally, the `-i false` option instructs `branch-name` to *not* prompt the user when creating projects. The aforementioned project folder will also contain the following files: readme.txt, scratch.rb and snippets.rb. In addition to this, `branch-name create` will also copy the feature brach name to the clipboard for you (macOS and Windows currently supported). This is convenient when you need to create a feature branch in github, or from the command-line.\n\n```shell\n$ branch-name create -i false -p -d -s - \"Pay down tech debt on User model\" LG-12345\n```\n\nNOTE: When creating projects, `branch-name` will prompt you if the `interactive` option is true (`-i`).\n\nThis example simply formulates feature a branch named *Add_create_and_destroy_session_controller_actions* and copies it to the clipboard.\n\n```shell\n$ branch-name create \"Add #create and #destroy session controller actions\"\n```\n#### Creating a Branch Name that Contains Forward-Slashes (`/`)\n\nThis can be accomplished in different ways; below are some examples,\n\n##### Embed the forward-slashes using the configuration format-string option\n\nSpecifically, the `--format-string/-x` option.\n\n```shell\n$ branch-name create -x \"%u/%t %d\" \"Remove debug code\" UX-54321\n#=\u003e Branch name: \u003cusername\u003e/ux-54321-remove-debug-code\n...\n```\n\n##### Embed the forward-slashes in the ticket description itself\n\nDepending on *where* you want your forward-slashes to appear, you'll have to place them appropriately:\n\n```shell\n$ branch-name create \"\u003cusername\u003e/UX-54321 Remove debug code\"\n#=\u003e Branch name: \u003cusername\u003e/ux-54321-remove-debug-code\n...\n```\n\nIf you want a more **pernament solution**, you can [change the configuration `format_string` string](#creating-feature-branch-names-and-projects-examples) to include forward-slashes.\n\nBelow is an example using forward-slashes and username using the `%u` format specifier (assuming it coincides with your current username): `format_string: \"%u/%t %d\"`\n\n```shell\n$ branch-name create \"Remove debug code\" UX-54321\n#=\u003e Branch name \"\u003cusername\u003e/ux-54321-remove-debug-code\"\n```\n\nLastly, you can, of course, embed a forward-slash or any other token and hard-code (for example) a username, just like any other token. The below is an example that would result if your configuration format_string looked like `format_string: \"jsmith/%t %d\"`.\n\n```shell\n$ branch-name create \"Remove debug code\" UX-54321\n#=\u003e Branch name \"jsmith/ux-54321-remove-debug-code\"\n```\n\nNOTE: Project folders that are formulated (`branch-name create [-p|--project] ...`), will have any tokens comprising the project folder name delimited according to the following rules: if the `options[:separator]` option (-s) is included in `Branch::Name::Normalizable::PROJECT_FOLDER_TOKEN_SEPARATORS`, `options[:separator]` (-s) will be used as the project folder token delimiter; otherwise, `Branch::Name::Normalizable::DEFAULT_PROJECT_FOLDER_TOKEN_SEPARATOR` will be used.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/branch-name. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/branch-name/blob/main/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Branch::Name project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/branch-name/blob/main/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgangelo%2Fbranch-name","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgangelo%2Fbranch-name","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgangelo%2Fbranch-name/lists"}