gioboa / jira-plugin

Jira plugin for VsCode
https://marketplace.visualstudio.com/items?itemName=gioboa.jira-plugin
MIT License
265 stars 41 forks source link

issue: if the branch name issue ID casing differs from the Jira project, the plugin gets confused #143

Closed gforrest-bw closed 4 years ago

gforrest-bw commented 4 years ago

Describe the issue

I use lowercase characters for my branch names. Our JIRA project ID is "UI", but my branches generally use ui.

When I utilize the feature to auto-select an issue based on branch name (which is very convenient!), the plugin tries to set my active project to ui, and it doesn't seem to work correctly, as evidenced by the error below.

To Reproduce

Steps to reproduce the behavior:

  1. Open a branch with a JIRA ID which has a different casing from your project's actual JIRA ID.
  2. Consent to auto-select the active issue based on branch name when prompted
  3. The plugin will report an error
  4. Restarting the editor, the plugin will again report the error on startup, until you change the project yourself.

Expected behavior

I expect the plugin to match the auto-detected project ID against the list of available IDs in a case-insensitive manner and choose the one which has the same exact characters, regardless of casing.

Screenshots

image

Desktop (please complete the following information):

Version: 1.42.1 (user setup) Commit: c47d83b293181d9be64f27ff093689e8e7aed054 Date: 2020-02-11T14:45:59.656Z Electron: 6.1.6 Chrome: 76.0.3809.146 Node.js: 12.4.0 V8: 7.6.303.31-electron.0 OS: Windows_NT x64 10.0.18362

Log

Working project not correct. Select working project in the status bar.
gforrest-bw commented 4 years ago

Reading through the source code I discovered the project key mapping setting, which I believe will patch over this problem if I set ui=UI. However, assuming JIRA project keys can only be uppercase, I think it would be more elegant for the plugin to do this conversion automatically. I'm not confident that JIRA project keys can only be uppercase, but I've never seen one that isn't.

gioboa commented 4 years ago

Hi, the plugin use this RegExp -> "branchName".match(/([A-Za-z0-9]+)-(\d+)/)

I will try to fix it. PR or help would be greatly appreciated. :+1:

gforrest-bw commented 4 years ago

The important part is that after it matches the issue ID, it capitalizes the project key before setting the active project.

I suppose that could happen on this line, maybe using a named function which "normalizes" the project key: https://github.com/gioboa/jira-plugin/blob/develop/src/services/git-integration.service.ts#L162

I might be able to make a PR sometime.

gioboa commented 4 years ago

I will fix it. 👍

gioboa commented 4 years ago

Here you can try an alpha version. Please have a try and give me feedback. :+1: If all it's ok, I will release a new official version. :smile: jira-plugin-0.19.1-alpha1.zip

gforrest-bw commented 4 years ago

I gave it a spin, and it seems to work - I didn't get any error messages, even after removing my ui=UI alias in settings.

gioboa commented 4 years ago

Thank you for your feedback :+1: