-
Notifications
You must be signed in to change notification settings - Fork 267
[Question] Documentation or Examples on Custom Actions #1479
-
Hi all,
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!
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 12 comments 9 replies
-
Beta Was this translation helpful? Give feedback.
All reactions
-
I configured two Custom Actions
in my local SourceGit
repository:
- Format Codes
Format the codes via dotnet format
command.
- Rebuild
Build & publish this project to D:\SourceGit
via wt -d "${REPO}" pwsh -NoExit -c "dotnet publish -c Release -o D:\SourceGit src\SourceGit.csproj"
command.
Beta Was this translation helpful? Give feedback.
All reactions
-
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:
- Repository (triggered via button in main toolbar, variable
${REPO}
expands to current repo-path) - Branch (triggered by right-click on branch, variable
${BRANCH}
expands to selected branch) - Commit (triggered by right-click on commit, variable
${SHA}
expands to selected commit)
NOTE: The configured action-command is started in the repository root-folder (i.e ${REPO}
).
Beta Was this translation helpful? Give feedback.
All reactions
-
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...) 😉
Beta Was this translation helpful? Give feedback.
All reactions
-
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ドル
, ...) :
Available types of Input Controls are TextBox
, Path Selector
, Checkbox
.
Beta Was this translation helpful? Give feedback.
All reactions
-
Additionally, a new Scope
-value of Tag
was added as a follow-up on feature-request #1457, along with a new related variable ${TAG}
:
Beta Was this translation helpful? Give feedback.
All reactions
-
Maybe a new Discussion could be started, where we can post ideas / scripts etc for useful Custom Actions?
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 2
-
@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.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
FYI, in #1466 there was added support for using the above mentioned scope-variables (${REPO}
etc) in the Default:
field when editing Custom Action Input 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
(viaecho "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...
Beta Was this translation helpful? Give feedback.
All reactions
-
Maybe a new Discussion could be started, where we can post ideas / scripts etc for useful Custom Actions?
@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?
Beta Was this translation helpful? Give feedback.
All reactions
-
NOTE: In #1482 there was added support for a new Custom Action Input Control type: ComboBox
(released in v2025.25).
Beta Was this translation helpful? Give feedback.
All reactions
-
Hi @goran-w and @love-linger ,
I have been able to work in it and I have followed your suggestions and comments to configure some custom actions related to the pull requests using Github CLI.
They are being very useful.
Many thanks!
I created this enhacement #1390 and I think that it would be very interesting to do the same for the custom actions.
Additionally it could be interesting:
- to assign a keystroke (or shortcut) to the custom action,
- to add custom validators to the
TextBox
control, for instance adding regular expressions or simple rules as numeric without decimals or so on.
Regards,
Alberto
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 2
-
to assign a keystroke (or shortcut) to the custom action, PR: #1639
I don't think you've understood this requirement. What he means is that when creating a Custom Action, you can assign a shortcut key to it.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 2
-
How was your approach to making the custom command with the PR?
@CleberRangel - Not a complete answer, but the PR commands in GitHub CLI are documented here: https://cli.github.com/manual/gh_pr
@AlbertoVPersonal - could you provide more details/examples from your use case?
@goran-w, thanks for the link. But I think it would be nice to have a built-in parameter for the name of the repo, today we have for the repo path.
Beta Was this translation helpful? Give feedback.
All reactions
-
How was your approach to making the custom command with the PR?
@CleberRangel - Not a complete answer, but the PR commands in GitHub CLI are documented here: https://cli.github.com/manual/gh_pr
@AlbertoVPersonal - could you provide more details/examples from your use case?
@goran-w, thanks for the link. But I think it would be nice to have a built-in parameter for the name of the repo, today we have for the repo path.
here you are,#1653
but
Beta Was this translation helpful? Give feedback.
All reactions
-
to assign a keystroke (or shortcut) to the custom action, PR: #1639
I don't think you've understood this requirement. What he means is that when creating a Custom Action, you can assign a shortcut key to it.
I was thinking in it:
when creating a Custom Action, you can assign a shortcut key to it.
This way you can run the Custom Action without use the contextual menu and improve my own/personal performance.
Beta Was this translation helpful? Give feedback.
All reactions
-
How was your approach to making the custom command with the PR?
@CleberRangel - Not a complete answer, but the PR commands in GitHub CLI are documented here: https://cli.github.com/manual/gh_pr
@AlbertoVPersonal - could you provide more details/examples from your use case?
I created it this way for my interest:
pr create --base 1ドル --head ${BRANCH} -a @me -d --fill-verbose -l "merge into dev"
I followed this page Github CLI PR command when I did it.
Beta Was this translation helpful? Give feedback.