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

Fix several issues with Pkg.pin() #17196

Merged
merged 2 commits into from
Jun 30, 2016
Merged

Fix several issues with Pkg.pin() #17196

merged 2 commits into from
Jun 30, 2016

Conversation

carlobaldassi
Copy link
Member

@carlobaldassi carlobaldassi commented Jun 29, 2016

  • Actually check out the branch after creation (fix Pkg.pin broken, test ineffective #17176)
  • Activate test in test/pkg.jl
  • Avoid trying to update a pinned package (and emit info message)
  • Allow to pin a package several times without producing errors
  • Fix the cases in which resolve() is called after a pin()

More tests should be added. I'm working on it, but in the meanwhile this could already be merged, if everything seems in order to people who actually know LibGit2 well.

cc @wildart

* Actually check out the branch after creation (fix #17176)
* Activate test in test/pkg.jl
* Avoid trying to update a pinned package (and emit info message)
* Allow to pin a package several times without producing errors
* Fix the cases in which resolve() is called after a pin()
# no need to resolve, branch will be from HEAD
should_resolve = false
LibGit2.head_oid(repo)
Copy link
Contributor

Choose a reason for hiding this comment

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

what was the logic error here?

Copy link
Member Author

Choose a reason for hiding this comment

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

resolve was being called when keeping the head fixed and not called when changing it, rather than the other way around.

The behaviour after the fix is the following (notice the info messages which tell you whether resolve was invoked or not):

julia> Pkg.pin("Example") # stay on head, resolve not invoked 
INFO: Creating Example branch pinned.526e34fd.tmp

julia> Pkg.pin("Example", v"0.4.0") # resolve invoked
INFO: Creating Example branch pinned.b1990792.tmp
INFO: No packages to install, update or remove

julia> Pkg.pin("Example", v"0.4.0") # no changes, resolve not invoked
INFO: Package Example is already pinned to the selected commit

julia> Pkg.pin("Example", v"0.4.1") # change commit, resolve invoked
INFO: Package Example: checking out existing branch pinned.526e34fd.tmp
INFO: No packages to install, update or remove

julia> Pkg.pin("Example") # no changes, resolve not invoked
INFO: Package Example is already pinned

julia> Pkg.free("Example") # free always calls resolve (may be changed, but it's not in this PR)
INFO: Freeing Example
INFO: No packages to install, update or remove

@carlobaldassi
Copy link
Member Author

Tests added. Should be ready to merge after review.

Note: I wrote an ugly macro in the test file in order to grab the package manager outputs and check them. Is there a better way to achieve that?

@tkelman
Copy link
Contributor

tkelman commented Jun 29, 2016

I wrote an ugly macro in the test file in order to grab the package manager outputs and check them

I think it might be doable without writing to a temp file, but I like what it achieves of making this test file less noisy - probably applicable for the rest of the file too. Maybe generically useful enough to put it somewhere more official later.

@carlobaldassi
Copy link
Member Author

Yes, I also thought about applying it to the rest of the file. It's quite some work though, and can be left to another PR. Avoiding temp files would certainly be an improvement.
I will also certainly use this functionality in the tests for #17132.

@wildart
Copy link
Member

wildart commented Jun 30, 2016

LGTM

@carlobaldassi
Copy link
Member Author

Thanks for the reviews!

@carlobaldassi carlobaldassi merged commit 6d5eb28 into master Jun 30, 2016
@carlobaldassi carlobaldassi deleted the cb/fixpkgpin branch June 30, 2016 18:16
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.

Pkg.pin broken, test ineffective
3 participants