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

[Contrib] Checkout a PR #6021

Merged
merged 35 commits into from
Mar 8, 2019
Merged

Conversation

sapk
Copy link
Member

@sapk sapk commented Feb 9, 2019

Could be impoved, but it seems to work.

For example, to check the PR #6007 simply do :
go run contrib/pr/checkout.go 6007
OR
make pr PR=6007

This will checkout PR and start with integration tests fixtures loaded.

There still seems to have problem with auth after login the user is not kept logged (and some repo are missing but that normal)

@codecov-io
Copy link

codecov-io commented Feb 9, 2019

Codecov Report

Merging #6021 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #6021      +/-   ##
=========================================
- Coverage   38.82%   38.8%   -0.02%     
=========================================
  Files         355     355              
  Lines       50253   50253              
=========================================
- Hits        19510   19502       -8     
- Misses      27913   27922       +9     
+ Partials     2830    2829       -1
Impacted Files Coverage Δ
models/unit.go 0% <0%> (-14.29%) ⬇️
models/repo_list.go 66.84% <0%> (-1.06%) ⬇️
routers/repo/view.go 41.08% <0%> (-1%) ⬇️

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 9fd8b26...d29abcf. Read the comment docs.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 9, 2019
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 9, 2019
@lafriks lafriks added the topic/build PR changes how Gitea is built, i.e. regarding Docker or the Makefile label Feb 17, 2019
@zeripath
Copy link
Contributor

@sapk do you think you can fix the issues you mentioned?

@sapk
Copy link
Member Author

sapk commented Feb 18, 2019

@zeripath Since it is mostly to ease validating UI PR and have some data to view, I didn't take time on that part. I think it is related to fixtures but can't find exactly why.

@lafriks
Copy link
Member

lafriks commented Feb 18, 2019

@zeripath I think fixing fixtures should be out of scope for this PR

@zeripath
Copy link
Contributor

I was meaning about keeping the user logged in, but if it's too hard to fix then we can ignore it as it's only contrib

Copy link
Member

@jolheiser jolheiser left a comment

Choose a reason for hiding this comment

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

I couldn't for the life of me figure out how to get it to retain auth, but the rest of these nits just came about as I used the contrib. I don't think any of my nits are blocking though, so I'll just leave them as comments.
It seems to work well enough otherwise. 😄
I will say this makes checking out PRs incredibly easy!

contrib/pr/checkout.go Outdated Show resolved Hide resolved
contrib/pr/checkout.go Outdated Show resolved Hide resolved
contrib/pr/checkout.go Outdated Show resolved Hide resolved
contrib/pr/checkout.go Outdated Show resolved Hide resolved
@jolheiser
Copy link
Member

jolheiser commented Feb 28, 2019

After testing this again with latest changes, now it seems to be complaining about unstaged changes, even though I have a clean working tree. Did you run into this at all?

EDIT: After changing the checkout method to

err = tree.Checkout(&git.CheckoutOptions{
	Branch: plumbing.ReferenceName(branch),
	Force: true,
})

it worked...not sure if an issue with my setup or if it is needed for some reason. It shouldn't need to force the reset, but perhaps something else in the code is causing a "dirty" working tree before checkout?

@lafriks
Copy link
Member

lafriks commented Feb 28, 2019

Would be nice to add shortcut to makefile for this, something like make pr 1234

@sapk
Copy link
Member Author

sapk commented Mar 2, 2019

@jolheiser I did run it but it seems to not really create the branch at checkout but only checkouting the ref.
The unstaged changes can maybe come from the fact that the source file is duplicated in the destination repo if it doesn't exist in this revision. I will look into it.

@sapk
Copy link
Member Author

sapk commented Mar 4, 2019

@jolheiser did you use the command on windows ?
On windows : I have the error message of unstaged changes
On linux : It doesn't complain and checkout the PR and to the rest but it doesn't create the branch that it should at fetch step.

I will debug more to find why.

@sapk
Copy link
Member Author

sapk commented Mar 4, 2019

I find the mistake for the linux but still have the error on windows. The current solution is to use Force: runtime.GOOS == "windows" to only force on windows. (like suggested by @jolheiser)

@lafriks To have a make target like that we should had some hacky code like :

ifeq (pr, $(firstword $(MAKECMDGOALS)))
  runargs := $(wordlist 2, $(words $(MAKECMDGOALS)), $(MAKECMDGOALS))
  $(eval $(runargs):;@true)
endif
.PHONY: pr
pr:
	$(GO) run contrib/pr/checkout.go $(runargs)

Or we could also use format like make pr PR=0000

.PHONY: pr
pr:
    (GO) run contrib/pr/checkout.go $(PR)

@jolheiser
Copy link
Member

I had been testing on Windows at the time, yes. Good to know it's resolved on Linux, as that's where I will probably be doing most of my dev work going forward.

The only issue I can think of is if Force would discard working changes the dev wanted but forgot to commit before using the contrib. (Although we have fairly few Windows devs afaik)

As for the Makefile, personally I think the second option looks cleaner, and I like the idea of not making the Makefile any messier.

@lafriks
Copy link
Member

lafriks commented Mar 4, 2019

I'm ok with second option for makefile

Makefile Outdated Show resolved Hide resolved
@techknowlogick techknowlogick merged commit 9d3732d into go-gitea:master Mar 8, 2019
@sapk sapk deleted the checkout-pr branch March 8, 2019 09:48
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. topic/build PR changes how Gitea is built, i.e. regarding Docker or the Makefile
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants