Working on testing out the Git sync in my lab environment against an Azure devops git repo. I setup a fresh repo, with main as the default branch name, setup my appsettings.json and restarted the service. Initially I was getting some failure errors, and finally settled on clearing the .git folder from the local system and restarted the server. When I did this, I got a successful sync! However, it’s synced up a ‘master’ branch instead of main, despite the fact that I specified branch name in the git section on appsettings.json.
I’ve haven’t been able to reproduce this. I have tried both GitHub and Azure DevOps repos and it works correctly.
In both instances, I have deleted the repository and started completely fresh. Then I set all the parameters in appsettings.json and start up Universal. It successfully clones the proper branch. In both cases I did not have a master branch and only a main\dev branch.
Here’s my log.
info: UniversalAutomation.Git.GitService[0]
Git repository does not exist. Initializing.
2021-07-05 01:02:29 [INFO] (Hangfire.Server.BackgroundServerProcess) Server laptop-496lauk8:24276:578f18e6 successfully announced in 195.5741 ms
2021-07-05 01:02:29 [INFO] (Hangfire.Server.BackgroundServerProcess) Server laptop-496lauk8:24276:578f18e6 is starting the registered dispatchers: ServerWatchdog, ServerJobCancellationWatcher, ExpirationManager, CountersAggregator, Worker, DelayedJobScheduler, RecurringJobScheduler...
2021-07-05 01:02:29 [INFO] (Hangfire.Server.BackgroundServerProcess) Server laptop-496lauk8:24276:578f18e6 all the dispatchers started
info: UniversalAutomation.GitSyncService[0]
Starting sync...
info: UniversalAutomation.GitSyncService[0]
Latest commit Id: 4be87e674825debfc66b5e4022795b9160832491, Number of changes since last sync: 1
info: UniversalAutomation.GitSyncService[0]
Sync done. Status Id: 1
I am using the 2.1.2 nightly build to test this but nothing has changed within the git service in a long time so I can’t imagine there are differences between the 2.0.3 build and this one.
What would be helpful is a log from either of your environments.
The following commit id is what is showing up in azure…
21-07-06T11:48:01.3215264-05:00 [INF] Script has 0 jobs to delete. (1676cac2)
2021-07-06T11:48:01.3215549-05:00 [INF] Groom date is: 6/6/2021 4:48:01 PM (6128188c)
2021-07-06T11:48:01.3225629-05:00 [INF] Old jobs: 0 (be620771)
2021-07-06T11:48:01.3227991-05:00 [INF] Finished groom job. (ccb4f234)
2021-07-06T11:48:02.3984189-05:00 [INF] Latest commit Id: c9c084d510b11c25fceedbf0906a281046977bb8, Number of changes since last sync: 4 (e6241a48)
2021-07-06T11:48:02.4000148-05:00 [INF] Sync done. Status Id: 2 (ed5396a1)
2021-07-06T11:48:02.4338962-05:00 [INF] Starting job using Process. (4d0a5a43)
2021-07-06T11:48:13.9365985-05:00 [INF] Starting job using Process. (4d0a5a43)
Also tried the same steps with a fresh branch called test. Only thing committed was a readme.
2021-07-06T12:02:40.9850251-05:00 [INF] Starting sync... (a444e9b8)
2021-07-06T12:02:41.3155035-05:00 [ERR] Failed to sync: "The current branch is configured to merge with the reference 'refs/heads/master' from the remote, but this reference was not fetched." " at LibGit2Sharp.Repository.MergeFetchedRefs(Signature merger, MergeOptions options)
at LibGit2Sharp.Commands.Pull(Repository repository, Signature merger, PullOptions options)
at UniversalAutomation.Git.GitService.Pull() in D:\a\universal\universal\src\UniversalAutomation.Git\GitService.cs:line 236
at UniversalAutomation.GitSyncService.TrySync() in D:\a\universal\universal\src\UniversalAutomation\Services\GitSyncService.cs:line 90
at UniversalAutomation.GitSyncService.Sync() in D:\a\universal\universal\src\UniversalAutomation\Services\GitSyncService.cs:line 60" (2d6ed692)
2021-07-06T12:02:44.0523504-05:00 [INF] Starting job using Process. (4d0a5a43)
2021-07-06T12:02:44.2349491-05:00 [INF] Now listening on: "http://[::]:5000" (d826f4b8)
2021-07-06T12:02:44.2352097-05:00 [INF] Application started. Hosting environment: "Production"; Content root path: "C:\Program Files (x86)\Universal\" (9029d6f8)
I stopped PSU service and deleted the .git folder from the repository. Then I used vscode to confirm source control wasn’t picking up anything git related in that repository folder, verified my appsettings.json git options (specifically branch name), and proceeded to start PSU Service. It creates a master branch as part of the startup.
Thanks. I’m jumping on a call with @mikedhanson today to see if I can get a better idea of what’s happening. I still can’t reproduce myself.
I actually searched the entire code-base for the word “master” and it only appears in the documentation so it must be some side effect of the git library that PSU uses.
The problem is that if the repository directory has any files in it, it will push to master rather than the selected branch. I’ve fixed that.
If the directory is completely empty, it will clone from the desired branch. This is what I kept doing.
I guess my question is what you’d expect expect this behavior to be. If you have files locally and git isn’t initialized, it’s going to attempt to push changes to the remote during start up (I just added a check to make sure it doesn’t do this if OneWay is on). If your repository directory is empty it will only try to clone.