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

Offen
#998 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
ObjectScript
Sterne
22
Forks
14
Ø Merge
1 T. 9 Std.
Gemergte PRs (30 T.)
5

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit SourceControl.Git.Utils:GetCurrentBranch() und RunGitCommandWithInput("ls-remote", ...), und verfolge dann ihre Verwendung ab Pull(1). Überprüfe, wie returnCode und errStream für nicht zugängliche Repositories behandelt werden; fertig ist es, wenn Git-Fehler mit der Fehlerausgabe sichtbar gemacht werden, statt als leerer Branch behandelt oder als übersprungener Pull behandelt zu werden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
git
Bereich
tooling
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Aktiv
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
68/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.