You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Question] Documentation or Examples on Custom Actions #1448
I am looking for detailed documentation or examples on how to use custom actions in SourceGit. Specifically, I need guidance on the following areas:
How to define and configure custom actions.
Best practices for implementing custom actions.
Additional Information
SourceGit Version: 2025.23
Operating System: Windows 11
Context
I am working on a project where I need to extend SourceGit's functionality by adding custom actions. However, I have not found sufficient documentation or examples to guide me through the process.
Any help or pointers to relevant resources would be greatly appreciated!
TIP: For interaction with remote GH-repos, GitHub CLI can be used from Custom Actions.
When contributing to SourceGit I use the following Custom Action, for quickly syncing my fork-repo (remote origin) against the SourceGit main-repo (remote upstream) without having to visit the repo-webpage (or do a reset & push on the local branch) :
This basically does "Fast-forward origin/develop to upstream/develop".
(I added the --force flag just to handle cases where the upstream branch was force-pushed by a maintainer...) 😉
FYI, as a spin-off from feature-request #1457, a new Input Controls feature (not yet released) was added for Custom Actions (along with new related variables $1, $2, ...) :
I am trying to do a pull request from the command line but I'm having issues. At this moment I am not going to post it because I have to put in more effort (or dedicate more time) before I can ask something coherent.
FYI, in #1466 there was added support for using the above mentioned scope-variables (${REPO} etc) in the Default: field when editing Custom Action Controls of type TextBox or Path Selector.
Another tip not mentioned above (or documented anywhere?) : if your Custom Action is calling a script (for example a Git Bash script, as illustrated below), you can make SourceGit display an error/warning popup by doing BOTH of these things:
Return a non-zero exit code from your script (exit 1 or similar).
Have your script output a suitable error/warning text to stderr (via echo "Message" >&2 etc).
NOTE: Text that your script outputs to stdout (via echo "Message" >&1 etc) is not displayed anywhere immediately visible, but can be inspected after-the-fact from the View Logs feature in SourceGit.
Here's how to use Git Bash (on Windows) as the scripting engine (here using an absolute path to the bash executable, this could perhaps be improved) :
TIP: Text/filepath arguments could contain spaces, so it's a very good idea to enclose these in quotes...
Activity
love-linger commentedon Jun 23, 2025
#1160
#1077
love-linger commentedon Jun 23, 2025
I configured two
Custom Actionsin my localSourceGitrepository:Format the codes via
dotnet formatcommand.Build & publish this project to
D:\SourceGitviawt -d "${REPO}" pwsh -NoExit -c "dotnet publish -c Release -o D:\SourceGit src\SourceGit.csproj"command.goran-w commentedon Jun 24, 2025
Custom Actions can be created either in the global Preferences or just for a single repo (in the Repository Configure dialog).
A Custom Action can be setup for one of 3 different scopes:
${REPO}expands to current repo-path)${BRANCH}expands to selected branch)${SHA}expands to selected commit)NOTE: The configured action-command is started in the repository root-folder (i.e
${REPO}).goran-w commentedon Jun 24, 2025
TIP: For interaction with remote GH-repos, GitHub CLI can be used from Custom Actions.
When contributing to SourceGit I use the following Custom Action, for quickly syncing my fork-repo (remote
origin) against the SourceGit main-repo (remoteupstream) without having to visit the repo-webpage (or do a reset & push on the local branch) :This basically does "Fast-forward origin/develop to upstream/develop".
(I added the
--forceflag just to handle cases where theupstreambranch was force-pushed by a maintainer...) 😉goran-w commentedon Jun 25, 2025
FYI, as a spin-off from feature-request #1457, a new Input Controls feature (not yet released) was added for Custom Actions (along with new related variables
$1,$2, ...) :goran-w commentedon Jun 25, 2025
Additionally, a new
Scope-value ofTagwas added as a follow-up on feature-request #1457, along with a new related variable${TAG}:goran-w commentedon Jun 25, 2025
Maybe a new Discussion could be started, where we can post ideas / scripts etc for useful Custom Actions?
AlbertoVPersonal commentedon Jun 26, 2025
@love-linger @goran-w Many thanks for your comments.
I am trying to do a pull request from the command line but I'm having issues. At this moment I am not going to post it because I have to put in more effort (or dedicate more time) before I can ask something coherent.
goran-w commentedon Jun 27, 2025
FYI, in #1466 there was added support for using the above mentioned scope-variables (
${REPO}etc) in theDefault:field when editing Custom Action Controls of typeTextBoxorPath Selector.Another tip not mentioned above (or documented anywhere?) : if your Custom Action is calling a script (for example a Git Bash script, as illustrated below), you can make SourceGit display an error/warning popup by doing BOTH of these things:
exit 1or similar).stderr(viaecho "Message" >&2etc).NOTE: Text that your script outputs to stdout (via
echo "Message" >&1etc) is not displayed anywhere immediately visible, but can be inspected after-the-fact from theView Logsfeature in SourceGit.Here's how to use Git Bash (on Windows) as the scripting engine (here using an absolute path to the bash executable, this could perhaps be improved) :
TIP: Text/filepath arguments could contain spaces, so it's a very good idea to enclose these in quotes...
goran-w commentedon Jun 30, 2025
@love-linger Maybe you (as maintainer) could simply use Convert Issue to Discussion on this issue, so it can be removed from the list of open Issues?