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).

Aperta
#998 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
ObjectScript
Stelle
22
Fork
14
Merge medio
1g 9h
PR unite (30g)
5

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
git
Ambito
tooling
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Attiva
Chiarezza
Abbastanza chiara
Idoneità per principianti
68/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.