Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Question] Documentation or Examples on Custom Actions #1479

AlbertoVPersonal started this conversation in Ideas
Discussion options

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!

You must be logged in to vote

Replies: 12 comments 9 replies

Comment options

You must be logged in to vote
0 replies
Comment options

I configured two Custom Actions in my local SourceGit repository:

  • Format Codes

Format the codes via dotnet format command.

Image

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

Image

You must be logged in to vote
0 replies
Comment options

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

You must be logged in to vote
0 replies
Comment options

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

Image

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

You must be logged in to vote
0 replies
Comment options

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ドル, ...) :

Image

Available types of Input Controls are TextBox, Path Selector, Checkbox.

You must be logged in to vote
0 replies
Comment options

Additionally, a new Scope-value of Tag was added as a follow-up on feature-request #1457, along with a new related variable ${TAG} :

Image

You must be logged in to vote
0 replies
Comment options

Maybe a new Discussion could be started, where we can post ideas / scripts etc for useful Custom Actions?

You must be logged in to vote
0 replies
Comment options

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

You must be logged in to vote
0 replies
Comment options

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 (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) :

Image

TIP: Text/filepath arguments could contain spaces, so it's a very good idea to enclose these in quotes...

You must be logged in to vote
0 replies
Comment options

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?

You must be logged in to vote
0 replies
Comment options

NOTE: In #1482 there was added support for a new Custom Action Input Control type: ComboBox (released in v2025.25).

You must be logged in to vote
0 replies
Comment options

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

You must be logged in to vote
9 replies
Comment options

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.

Comment options

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.

Comment options

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

Comment options

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.

Comment options

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
question Further information is requested
Converted from issue

This discussion was converted from issue #1448 on July 01, 2025 01:17.

AltStyle によって変換されたページ (->オリジナル) /