AtlassianPS / JiraPS

PowerShell module to interact with Atlassian JIRA
https://AtlassianPS.org/module/JiraPS
MIT License
323 stars 131 forks source link

fixes 320 - assignment when similar users exist #328

Closed michalporeba closed 5 years ago

michalporeba commented 5 years ago

Description

Adds -Exact parameter to the Get-JiraUser which internally switches from using search to get user. It is then used in the Set-JiraIssue when the -Assignee is set.

Motivation and Context

closes #320 closes #49 is continued by #306 Assigning users failing when Get-JiraUser for a specific username returns more than one user

Types of changes

Checklist

michalporeba commented 5 years ago

I have a unit test to cover the -Exact option and modified one to be more explicit how the Get-JiraUser should work when the -Exact is not used. I have also updated the Get-JiraUser documentations.

stevenyoungs commented 5 years ago

Hi @michalporeba I believe there are many places where Get-JiraUser is called, internally, and each would need to be investigated and potentially suffixed with the new -Exact switch. Additionally, any external call to Get-JiraUser would need to be evaluated and potentially suffixed with -Exact. The approach I took with #306 was to modify the default behaviour of Get-JiraUser so that it does what your -Exact switch does. The upside as I see it is that, for the most common case of finding an exact user, no further source modifications are required; it 'just works!' As mentioned elsewhere, it is a breaking change and @lipkau, understandably, wants to wait for the next major release. Much as I would personally love to see this problem fixed sooner, I don't disagree with the decision to await the next major release.

@lipkau do you have a schedule in mind for releasing 3.0?

michalporeba commented 5 years ago

As far as I see the failing tests are to do with documentation, I would need some guidence there to make it work, but let's talk about the two solutions.

Your change @stevenyoungs fixes much more than what I'm trying to achieve. The filter appears to be good long term solution, but it is a breaking change. Not only internally, but in any script people might have written using it.

My approach has only two things in mind. Fix the problem with assigning users and make sure the impact is minimal. The -Exact switch has the default value of $false and when it is false, there are no changes to the behaviour of JiraPS. The behaviour changes only when the switch is set to $true, and that is used only in one place in Set-JiraIssue. That makes the change very localised and easy to test. While it doesn't resolve much bigger problem, it solves one specific bug and could be successfully used in the current bersion before 3.0 is ready. Also, because it is a fix to that specific issue and not a replacement for your solution to the bigger problem I don't see why the -Exact would have to be added to the other commands.

lipkau commented 5 years ago

@stevenyoungs : I don't think this PR is the ideal solution for this matter. but as it has been raised a lot of times (and is a very old issue), I would allow this change to pass and refactor it with #306 for the next major version. hope you agree

michalporeba commented 5 years ago

Thanks for the information and review. I will make the changes tomorrow morning.

michalporeba commented 5 years ago

Thank you @lipkau for solving the documentation problem for me. Can you explain what it was? Was it just the missing ### -Exact above the yml section I have added? Is the parameter type difference important? I have seen in other places SwitchParameter used and you changed it to Switch.

lipkau commented 5 years ago

### is markdown for <h3/>. So the name of the parameter must be the header for the description and yaml table.

you can see how that looks like in html on the documentation page: https://atlassianps.org/docs/JiraPS/commands/Get-JiraUser/#parameters