NppEventExec to github
-
I’m learning to use github, in short, I need to learn a lot at the same time.
My programming knowledge is “beginner”, because I worked a long time as a DBA (data base analyst), and I got little involved with programming.
Now I’m learning php, and needing to put files on github, and it seemed to me that this plugin, can be used to minimize the whole process of accessing git and making updates (or am I wrong?).
If possible, could someone post a template.
Anyway, congratulations to Mihail Ivanchev, because even if it’s not possible for my intentions, it seems like a great job.
I appreciate any help -
That plugin is new to me. But it seems to hook NPPN_* events and run NppExec scripts.
So, you would need to make an NppExec Script that will commit your project to GitHub – probably something that did a
commit
to your local repo, and apush
to the GitHub repo. And then you could then hook the NPPN_FILESAVED event to call that NppExec script.To do anything beyond that would require you to write the scripts that do the git/github actions you desire, and then figuring out which NPPN_* event best matches when you’d want that to.
You can look my NppExec + SVN examples below, and base your git scripts on those. However, I highly suggest investigating the Better Idea first:
Better Idea
I would recommend looking at the GitSCM plugin instead: that probably has all the functions you would want/need, without having to figure out a script for each of them, or hassle with hooking them to the right events.
NppExec + SVN examples
Personally, for my subversion-based version control, I have four NppExec scripts, which commit the current dir, commit the current file, add the current dir, and update the current dir. And I just entries in my
contextMenu.xml
(Settings > Edit Popup ContextMenu) that call those scripts, so I do it manually rather than on triggers. But even knowing that they can be done on triggers, I doubt I would do them, since not all my files are in subversion control, so I don’t want it trying to run the “commit” script every time I save a file that isn’t in subversion.if you want to use my svn scripts as templates for the same concepts that you would use for git, I will include them below. However, you will not want to do the NPP_SAVE command in each if you are going to be triggering off of the NPPN_FILESAVED event, because that will cause an infinite loop
::Svn-Commit-Dir NPP_SAVE cd "$(CURRENT_DIRECTORY)" INPUTBOX "SVN commit $(CURRENT_DIRECTORY)" : "Message: " : cmd /c svn commit -m "$(INPUT)" cmd /c svn update ::Svn-Commit-File NPP_SAVE cd "$(CURRENT_DIRECTORY)" INPUTBOX "SVN commit $(FILE_NAME)" : "Message: " : cmd /c svn commit "$(FILE_NAME)" -m "$(INPUT)" cmd /c svn update "$(FILE_NAME)" ::Svn-Add-File NPP_SAVE cd "$(CURRENT_DIRECTORY)" cmd /c svn add "$(FILE_NAME)" ::Svn-Update cd "$(CURRENT_DIRECTORY)" cmd /c svn update .
(and no, I will not rewrite those to work for git/github for you. the concepts you need are all there, and translating those concepts to git will help you learn the tool.)