Skip to content

If local GIT Repo is not available to the user running git pull, process will fail (silently in some cases). #998

Description

@pisani

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions