How to automatically add files created by `rails generate` to VCS?

Does anyone know if this is possible?  I'd like the files created by running a generator in the RubyMine IDE to be added to my VCS (mercurial) automatically.  I don't mind writing a plugin or getting fancy if someone can point me in the right direction.

Thanks,

1 comment

Hello David,

If files are generated inside RubyMine and created through VFS, VCS listener will be aware of them and settings in Settings | Version Control | Confirmation
applies to the case.

If files are created in other way (not through VFS), you can add them programmatically through:

/* public final RefreshSession createSession(boolean async, boolean recursive, @Nullable Runnable finishRunnable) */
!!! finishRunnable is called _under write action_
be careful

    final RefreshSession session = RefreshQueue.getInstance().createSession(true, true, new Runnable() {

      public void run() {

        // here in callback files are already known to VFS and now we can add them
    final ChangeListManagerImpl changeListManager = ChangeListManagerImpl.getInstanceImpl(project));
    changeListManager.addUnversionedFiles(changeListManager.getDefaultChangeList(), unversionedFiles);
// files will be visible in change list manager after its inner update. not synchronously after this call
      }
    });

    session.addAllFiles(myFilesToRefresh);
    session.launch();     // starts refresh

0

Please sign in to leave a comment.