Wolfram Research

Function Repository Resource:

ShowGitStatus

Source Notebook

Display the status of a git repository

Contributed by: Michael Sollami

ResourceFunction["ShowGitStatus"][]

returns the status of the git repository in the working Directory[].

ResourceFunction["ShowGitStatus"][dir]

returns the status of the git repository located in the given directory dir.

Details and Options

Assuming a valid git repo is found, ResourceFunction["ShowGitStatus"] returns one of four string values: "Untracked files present", "Unstaged changes", "Unpushed commits", "Working directory clean".
ResourceFunction["ShowGitStatus"] accepts the following options:
Appearance"Styled"the format of the output
"GitPath"Automaticthe location of the git executable
The possible values for Appearance are:
"String"an unstyled string indicating status
"Styled"a status string with additional font coloring to indicate status
"Tooltip"a colored icon with the status in a tooltip
When "GitPath" is Automatic, ResourceFunction["ShowGitStatus"] uses platform-dependent system commands to find git executables:
Linuxwhichsystem installed git
MacOSwhichgit installed with brew
Windowswheresystem installed git
If the path to the git executable cannot be determined automatically, the absolute path should be provided to the option "GitPath"

Examples

Basic Examples (2) 

Check if a directory is a git repo:

In[1]:=
SetDirectory["~/Documents/rd"];
ResourceFunction["ShowGitStatus"][]
Out[2]=

Visualize the git status of any path:

In[3]:=
ResourceFunction["ShowGitStatus"]["~/Downloads/rd"]
Out[3]=
In[4]:=
ResourceFunction["ShowGitStatus"]["~/Documents/dsblog"]
Out[4]=
In[5]:=
ResourceFunction["ShowGitStatus"]["~/repos/torch"]
Out[5]=

Options (1) 

Change the appearance of the returned status:

In[6]:=
ResourceFunction["ShowGitStatus"]["~/Downloads/rd", Appearance -> #] & /@ {"Tooltip", "StyledString", "String"}
Out[6]=

Publisher

Michael Sollami

Version History

  • 1.0.0 – 08 February 2021

Related Resources

License Information