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

Exposed the value accessor in Context #741

Merged
merged 2 commits into from Nov 18, 2019

Conversation

corruptmemory
Copy link
Contributor

I wrote a small utility to populate a struct reflectively from command-line-arguments, but to do this I needed to get at the values stored via value.

@AudriusButkevicius
Copy link
Contributor

Not sure why? I've written something simillar and not sure I needed that.

@coilysiren
Copy link
Member

👋 @corruptmemory if you're still interested in this PR, can you respond to AudriusButkevicius's comment above? If not - feel free to ignore this ping, and we can close the PR so it won't become stale.

@AudriusButkevicius
Copy link
Contributor

actually, it's not a unreasonable change.

I am using reflection on the destination, and then based on that I pick the "getter", so it's reasonable to want to do the inverse.

@corruptmemory
Copy link
Contributor Author

Nice to see some life coming to the PR. I'll rebase and push sometime this weekend.

@coilysiren
Copy link
Member

Oh no, this PR has been assailed by merge conflicts! @corruptmemory can ya take care of that?

@coilysiren
Copy link
Member

👋 heya, I think I'll close this within the next ~week if you don't have time for it @corruptmemory! You are very much encouraged to re-open it later, though 🙏

@corruptmemory
Copy link
Contributor Author

Sorry for the late response. I'll clean this up this week.

@codecov
Copy link

codecov bot commented Oct 22, 2019

Codecov Report

Merging #741 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #741   +/-   ##
=======================================
  Coverage   72.89%   72.89%           
=======================================
  Files          32       32           
  Lines        2439     2439           
=======================================
  Hits         1778     1778           
  Misses        550      550           
  Partials      111      111
Impacted Files Coverage Δ
context.go 94.16% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 754ed1b...615e70e. Read the comment docs.

@corruptmemory
Copy link
Contributor Author

I see that there is now a collision between calling (*context.Context).Value(interface{}) and (*cli.Context).Value(string) and the second one is winning causing the NPE.

This change in line 331 in context_test.go seems to address the issue:

val := ctx.Context.Value("key")

Copy link
Member

@saschagrunert saschagrunert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense. LGTM

@coilysiren coilysiren merged commit 108d39a into urfave:master Nov 18, 2019
@coilysiren coilysiren mentioned this pull request Dec 24, 2019
@Napas
Copy link

Napas commented Jan 13, 2020

@lynncyrin This PR introduces breaking changes.

Value(string) interface{} overrides Value(interface{}) interface{} from the context.Context and cli.Context stops implementing context.Context interface.

Please revert it ASAP.

@asahasrabuddhe
Copy link
Member

@Napas Are you using a dependency management system? I think not. I would suggest that pin to a release prior to v2.1.0 instead of getting the latest code directly from the master.

@Napas
Copy link

Napas commented Jan 13, 2020

@Napas Are you using a dependency management system? I think not. I would suggest that pin to a release prior to v2.1.0 instead of getting the latest code directly from the master.

I am doing that until it will be reverted, but minor version release should not have breaking changes.

On top of that, it makes testing much harder as cli.Context can't have mocked and used as context.Context downstream.

@coilysiren
Copy link
Member

I'll revert this now, but just so it's 100% clear - there's no specific reason why reverting this should be blocked on me. Anyone can submit a reversion PR.

coilysiren added a commit that referenced this pull request Jan 13, 2020
This reverts commit 108d39a, reversing
changes made to 754ed1b.
@coilysiren
Copy link
Member

@Napas @asahasrabuddhe => #1039

@coilysiren
Copy link
Member

I am doing that until it will be reverted, but minor version release should not have breaking changes

Just in case anyone isn't aware - by no means did anyone involved in this PR merge a breaking change on purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants