Plugins/VcsPlugins/vcsGit/GitStatusMonitorThread.py

changeset 6529
1c2968f124b7
parent 6048
82ad8ec9548c
child 6645
ad476851d7e0
equal deleted inserted replaced
6528:3e194fec0eaa 6529:1c2968f124b7
128 self.reportedStates = states 128 self.reportedStates = states
129 129
130 return True, \ 130 return True, \
131 self.tr("Git status checked successfully") 131 self.tr("Git status checked successfully")
132 132
133 def _getInfo(self):
134 """
135 Protected method implementing the real info action.
136
137 This method should be overridden and create a short info message to be
138 shown in the main window status bar right next to the status indicator.
139
140 @return short info message
141 @rtype str
142 """
143 args = self.vcs.initCommand("show")
144 args.append("--abbrev-commit")
145 args.append("--format=%h %D")
146 args.append("--no-patch")
147
148 output = ""
149 process = QProcess()
150 process.setWorkingDirectory(self.projectDir)
151 process.start('git', args)
152 procStarted = process.waitForStarted(5000)
153 if procStarted:
154 finished = process.waitForFinished(30000)
155 if finished and process.exitCode() == 0:
156 output = str(process.readAllStandardOutput(),
157 Preferences.getSystem("IOEncoding"),
158 'replace')
159
160 if output:
161 commitId, refs = output.splitlines()[0].strip().split(None, 1)
162 ref = refs.split(",", 1)[0]
163 if "->" in ref:
164 branch = ref.split("->", 1)[1].strip()
165 else:
166 branch = self.tr("<detached>")
167
168 return self.tr("{0} / {1}", "branch, commit").format(
169 branch, commitId)
170 else:
171 return ""
172
133 def _shutdown(self): 173 def _shutdown(self):
134 """ 174 """
135 Protected method performing shutdown actions. 175 Protected method performing shutdown actions.
136 """ 176 """
137 if self.__client: 177 if self.__client:

eric ide

mercurial