Help with git for testing Addon Manager
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Help with git for testing Addon Manager
I'm writing some tests for the Addon Manager, and of course one of the things that I want to test is checking for updates. In the context of a unit test, what I need to do is check out some Addon at some past revision, and then make git think that rather than being in a detached head state, it is just out-of-date. Or something equivalent. Can anyone who is better at git than me give me some pointers to how to achieve something like that?
- adrianinsaval
- Veteran
- Posts: 5552
- Joined: Thu Apr 05, 2018 5:15 pm
Re: Help with git for testing Addon Manager
how about
Code: Select all
git reset --hard {commit_hash}
Re: Help with git for testing Addon Manager
To my knowledge, you can only achieve this in a branch.
Re: Help with git for testing Addon Manager
When I try that, "git fetch" doesn't return anything, it acts like it is up-to-date.adrianinsaval wrote: ↑Tue Aug 09, 2022 7:28 pm how aboutCode: Select all
git reset --hard {commit_hash}
Re: Help with git for testing Addon Manager
Is that a problem to use a branch for the test?
Code: Select all
git checkout @^1 -B test_branch
- adrianinsaval
- Veteran
- Posts: 5552
- Joined: Thu Apr 05, 2018 5:15 pm
Re: Help with git for testing Addon Manager
well fetching is not the correct way to check for updates, you need to compare the remote to the local checked out state, what if I run git fetch on an outdated addon? the checked out copy remains outdated but if I run git fetch again I'll get nothing.
git fetch would still return nothing so it's no different than git reset --hardopenBrain wrote: ↑Tue Aug 09, 2022 8:48 pm Is that a problem to use a branch for the test?Code: Select all
git checkout @^1 -B test_branch
If you really want to have git fetch return something again I think you can do this:
Code: Select all
git update-ref refs/remotes/origin/master refs/remotes/origin/master@{1}
Last edited by adrianinsaval on Tue Aug 09, 2022 9:12 pm, edited 1 time in total.
Re: Help with git for testing Addon Manager
Yeah, I wasn't sure if the original author had some particular reason to use fetch, though, so I didn't change it. I was hoping to test the code as-is before I did anymore refactoring, but it seems like that's not feasible, I am having to refactor just to enable testing! Oh well...
Re: Help with git for testing Addon Manager
In git isn't one always technically on a branch? Anyway, that type of checkout lands you in a detached head state, doesn't it?openBrain wrote: ↑Tue Aug 09, 2022 8:48 pm Is that a problem to use a branch for the test?Code: Select all
git checkout @^1 -B test_branch
Re: Help with git for testing Addon Manager
Using which command?adrianinsaval wrote: ↑Tue Aug 09, 2022 8:53 pm you need to compare the remote to the local checked out state
Re: Help with git for testing Addon Manager
Oh sorry -- although it does do a fetch every time, it's really looking at the output of git status to determine the up-to-date status. Nevertheless, if I specifically reset to a specific revision, git status returns nothing.