intersystems / intersystems/git-source-control
If local GIT Repo is not available to the user running git pull, process will fail (silently in some cases).
- Dominant language
- ObjectScript
- Stars
- 22
- Forks
- 14
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 5
Description
This was discovered whilst diagnosing a CICD pipeline which execute ##class(SourceContorl.Git.API.).Pull(1), by a GitHub Runner - once, the runner is setup (on Windows) to run as a service.
When setup, by default the Service windows identity is NETWORK_SERVICE. This windows account will have access to the windows folder containing the repository, but the ownership would typically be different.
the Pull(1) method executes
- **git branch --show-current** invoked via the method SourceControl.Git.Utils:GetCurrentBranch(), then executes
- **git ls-remote ** invoked by calling ##class(SourceControl.Git.Utils).RunGitCommandWithInput("ls-remote" ...)
the GetCurrentBranch() never checks error codes, and if it got a branch and in the case of the GitHub Runner service (and a GIT environment not set to make this repo also available to NETWORK_SERVICE), will raise the error (that is logged) saying the command failed fatally as the repo couldnt be accessed.
GetBranch() returns "", and no error condition - and then proceeds to run the second command, which also fails (and doesn't check for failure), but simply reports "Skipping pull because remote branch does not exist".
We need to make all git command handle failures, and this is no exception so I would propose
1. SourceControl.Git.Utils:GetCurrentBranch() take to arguments byRef, returnCode and errStream, and, if returnCode >0, writes out errStream content and quits with error.
2. ##class(SourceControl.Git.Utils).RunGitCommandWithInput("ls-remote",..., interprets returnCode and if >0 writes out errStream content and quits with error.
Steve
Contributor guide
Research direction
Start with SourceControl.Git.Utils:GetCurrentBranch() and RunGitCommandWithInput("ls-remote", ...), then trace their use from Pull(1). Verify how returnCode and errStream are handled for inaccessible repositories; done means git failures are surfaced with the error output instead of being treated as an empty branch or skipped pull.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100