def _create_tag(self): sha1 = self._clicked_item.commit.sha1 createtag.create_tag(revision=sha1)
def main(context): """Parses the command-line arguments and starts git-cola """ setup_environment() opts, args = parse_args(context) repo = process_args(opts, args) # Allow Ctrl-C to exit signal.signal(signal.SIGINT, signal.SIG_DFL) # Initialize the app app = ColaApplication(sys.argv) # Ensure that we're working in a valid git repository. # If not, try to find one. When found, chdir there. model = cola.model() valid = model.set_worktree(repo) and not opts.prompt while not valid: startup_dlg = startup.StartupDialog(app.activeWindow()) gitdir = startup_dlg.find_git_repo() if not gitdir: sys.exit(-1) valid = model.set_worktree(gitdir) # Finally, go to the root of the git repo os.chdir(model.git.worktree()) # Prepare to launch a sub-command builtins = set(('cola', 'classic', 'dag', 'fetch', 'pull', 'push', 'stash', 'tag')) if context != 'git-dag' and args and args[0] in builtins: context = args[0] # Show the GUI if context == 'git-cola' or context == 'cola': view = MainView(model, qtutils.active_window()) ctl = MainController(model, view) elif context == 'git-dag' or context == 'dag': ctl = git_dag(model, opts=opts, args=args) view = ctl.view elif context == 'classic': view = cola_classic(update=False) # TODO: the calls to update_status() can be done asynchronously # by hooking into the message_updated notification. elif context == 'stash': model.update_status() view = stash().view elif context == 'fetch': model.update_status() view = guicmds.fetch().view elif context == 'pull': model.update_status() view = guicmds.pull().view elif context == 'push': model.update_status() view = guicmds.push().view elif context == 'tag': view = create_tag().view # Install UI wrappers for command objects cfgactions.install_command_wrapper() guicmds.install_command_wrapper() # Make sure that we start out on top view.show() view.raise_() # Scan for the first time task = _start_update_thread(model) # Start the inotify thread inotify.start() msg_timer = QtCore.QTimer() msg_timer.setSingleShot(True) msg_timer.connect(msg_timer, SIGNAL('timeout()'), _send_msg) msg_timer.start(0) # Start the event loop result = app.exec_() # All done, cleanup inotify.stop() QtCore.QThreadPool.globalInstance().waitForDone() pattern = cola.model().tmp_file_pattern() for filename in glob.glob(pattern): os.unlink(filename) sys.exit(result) return ctl, task