-
Notifications
You must be signed in to change notification settings - Fork 6
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
Clone repo normally #35
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@HebaruSan this is the thing I fought with for hours when it came to staging. Using clone_from
doesn't map the refs properly. :-(
I'm probably gonna drop that create_remote
and call out to the git cli directly (which you can do with repo.git.<function>()
.
Howso? I didn't notice any problems when I was trying it out. |
The ref mapping. It's very subtly different. I spent hours debugging the staging process, only to figure out the clone was where the problem was. d485953 |
Can you give me a hint of where to look to see that? I'm suspicious that we appear to have had a bug that was fixed by introducing another bug, suggesting that the original problem may have been something other than it appeared. |
That's exactly how |
It was this mapping here, I don't have the example specifically though this is an example of what it looks like: [remote "origin"]
url = /tmp/tmpnvd6f81d/upstream
fetch = +refs/heads/*:refs/remotes/origin/* I think this is how it was configuring it from memory. [remote "origin"]
url = /tmp/tmpnvd6f81d/upstream
fetch = +refs/heads/master:refs/remotes/origin/master Which relates to the refspec. I definitely introduced a new bug fixing it, however reverting it will cause it to blow up when it hits a staging branch on a fresh clone. Worst case scenario we can just inject the master block config into the config and move on 🤷♂️ [branch "master"]
remote = origin
merge = refs/heads/master I feel I'm missing something stupidly obvious somewhere, but the documentation is a little tough to follow. |
Interesting. I wonder what option I was failing to pass that makes it behave like the cli version. |
I think we should write a test case for the clone. One that matches the desired output of the config, cause we have come unstuck several times by this. Manually setting that master block does fix it and I reckon I can massage the bot a little to prove that. The repo only gets brought into memory when the context manager is active (it leaks memory, so gets closed after every block sqs batch) |
OK, so this script: import os, sys, git, pathlib
url = "https://github.com/KSP-CKAN/CKAN-meta.git"
dir = pathlib.Path("cloned")
repo = git.Repo.clone_from(url, dir) Generates this
And running
I'm not seeing a problem with |
Thanks for your persistence @HebaruSan - I'll check this branch when I have a coffee and see if I can repeat the error I had. It might even be down to the git version in the container, maybe its newer and the defaults are done differently. If it works I'll go ahead and merge it. |
I do note that we're doing a full clone here, but I can't replicate the fault either way (shallow or full). Thanks for persisting, I literally have no idea why that wasn't working last week when I was doing the testing. But honestly it's been the week for it and I'm looking forward to going home and resting! |
Are the repos used by the various containers persistent? If so, we should delete them so they can be re-cloned to get the benefits of this fix. |
Nope, they are re-cloned on container redeploy. So it should be all done now in theory :-) |
Problem
As @techman83 noted (see #33 (comment)), the new bot's git repos aren't being created properly.
A regular git clone's
.git/config
file:The
.git/config
file from the new bot's repo:Cause
The new bot attempts to set up its git repos manually in multiple steps:
mkdir
,init
,create_remote
, andpull
. This leaves out the step of setting the upstream for the master branch.Changes
Now we use
clone_from
to set up the working dir normally. This will take care of the whole process for us in one step.In a dir set up with the old code:
In a dir set up with the new code:
Note the new bit about "up to date with 'origin/master'". This means the upstream is set for the branch.
May relate to #33, but I'm not sure about that. I had expected the problem to relate more to the Perl web hook code and/or how it's configured, since the problem in that issue happens immediately without waiting for the new bot to mess things up.