Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatic Xcode Git Commit Prompts [closed]

I easily forget to regularly make local git commits, and so i've developed the bad habit of having a few very large commits. I'd really like to make lots of small commits. Largely so the messages are more explicit.

I know myself well enough to know that this isn't just going to magically happen by me remembering. I'm more likely to be successful if I implement a system that pushes me to do this.

Here's what I'd like, either an Xcode plugin, an Applescript or an xCode behavior trigger that systematically initiates the commit command (cmd-option c) within Xcode (or i suppose i'd explore alternatives, but it'd be nice to stay within xCode). It can do this either based on the number of files changed, or amount of time elapsed, or possibly on a "build and run" or any other reasonable behavior. At any rate, i'd like for it to be somewhat configurable and where it could be enabled and disabled easily.

So is there something this already out there? If not, do you have any guidance on how I might get started with a potential solution.

like image 290
hatunike Avatar asked Feb 18 '26 07:02

hatunike


1 Answers

Interesting Question

You might want to extrapolate from the following code found on this website. One might generate a unique but standardized text message combined with a folder name/date combination as the automated commit message or take the script and make it runnable to accept a parameter as input with the message being the parameter. I suppose though that might be as much work as typing git commit in the terminal. Instead you may want to use this script in combination with Folder Actions to monitor activity on a folder with the script acting as a service.

(* Copyright (C) 2012 Collin Donnell

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *)

tell application "Finder"
    set current_path to (POSIX path of (target of front window as alias))
    set commit_message to text returned of (display dialog "Commit message: " buttons {"Cancel", "Commit"} with title "Commit All" cancel button "Cancel" default button "Commit" default answer "")
    try
        do shell script ("cd \"" & current_path & "\"; git commit -am" & quoted form of commit_message)
    on error the_error
        display dialog the_error buttons {"OK"} with icon caution with title "Error"
    end try
end tell
like image 198
Tommie C. Avatar answered Feb 20 '26 22:02

Tommie C.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!