Is This a Good Use For Macros?

Due to the recent post on Macros I decided to give them a go for the first time.
Since, using git I have been using a rebase workflow to make merging and pushing easy
e.g.
branch, work, commit etc
switch to master
update
switch to branch
rebase to master

These last 4 steps seemed to be an ideal target for a macro.
However, what I end up with after recording is:
Action.Vcs.UpdateProject
Keystroke: "ENTER"
Action: GitRebase

Is this a bug or is this not the sort of thing that the macros were targetted at?
Am I better off writing a shell script and running it as an external tool?

0
4 comments

The script I have written looks like this:

#!/bin/bash
branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
git checkout master
git stash
git pull
git checkout $branch
git rebase -v -m refs/heads/master
git stash pop


I have managed to create git bash as an external tool and I can run it from there, but it would be nice to be able to run it from within IDEA.
Is there any way for me to do these steps as one within IDEA or can IDEA call the script directly somehow?

0

Hello,

Well, 'update project' action does the same steps (you can always open 'Version Control' tool window and see the exact git commands executed under the covers).

Regarding calling the external tools - please check this page.

Denis

0

Hi Denis,

I don't think that IDEA, exactly duplicates this script since if I create a branch, make a few commits then try update project I get the following error:

Can't update: no tracked branch
     No tracked branch configured for branch work.
     To make your branch track a remote branch call, for example,
     git branch --set-upstream work origin/work


My script finds out the name of the current branch, switches to master, updates there, then switches back to the original branch and rebases.
It doesn't matter if it is a local branch or not.

The Command Line Tools Support looks quite interesting though.
I am a little surprised that the plugin is included in PHPStorm and not IDEA Ultimate.
I guess you are more likely to need it in php work.

Anyway, it doesn't seem to work to work for me.
I get this error all the time

> dir
Cannot run program "dir" (in directory "D:\Projects\source\clean"): CreateProcess error=2, The system cannot find the file specified


Also, for my script to work in the Command Line Tools toolwindow I'd have to have the git bash console loaded.
Is that possible?

0

Hi!

What do you input when you get error about dir?  Looks like you should use command "sh <path to script>".

Also it might be more useful to use script as external tool (Settings | External Tools) with your script as program (it should be executable), ${ProjectFileDir} as working directory. Then you would be able to invoke it from various menus, and you don't need to remember exact script path.

Elena

0

Please sign in to leave a comment.