Skip to content

[Question] Documentation or Examples on Custom Actions #1448

Description

@AlbertoVPersonal

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!

Activity

  1. love-linger commented on Jun 23, 2025

    @love-linger
    Collaborator
  2. self-assigned this
    on Jun 23, 2025
  3. love-linger commented on Jun 23, 2025

    @love-linger
    Collaborator

    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

  4. goran-w commented on Jun 24, 2025

    @goran-w
    Contributor

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

  5. goran-w commented on Jun 24, 2025

    @goran-w
    Contributor

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

  6. goran-w commented on Jun 25, 2025

    @goran-w
    Contributor

    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

  7. goran-w commented on Jun 25, 2025

    @goran-w
    Contributor

    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

  8. goran-w commented on Jun 25, 2025

    @goran-w
    Contributor

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

  9. AlbertoVPersonal commented on Jun 26, 2025

    @AlbertoVPersonal
    Author

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

  10. goran-w commented on Jun 27, 2025

    @goran-w
    Contributor

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

    Image

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

  11. goran-w commented on Jun 30, 2025

    @goran-w
    Contributor

    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?

  12. Repository owner locked and limited conversation to collaborators on Jul 1, 2025
  13. converted this issue into a discussion #1479 on Jul 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions