# HG changeset patch # User Marcin Kuzminski # Date 2017-08-24 16:44:31 # Node ID 971549ceda87c62f44acf9bc21aa1d5d42097286 # Parent 678ed37822036409ea1427e748e1b59fc9c9b5b0 git: added identify command for checking the current checkout commit diff --git a/rhodecode/lib/vcs/backends/git/repository.py b/rhodecode/lib/vcs/backends/git/repository.py --- a/rhodecode/lib/vcs/backends/git/repository.py +++ b/rhodecode/lib/vcs/backends/git/repository.py @@ -704,6 +704,19 @@ class GitRepository(BaseRepository): cmd.append(branch_name) self.run_git_command(cmd, fail_on_stderr=False) + def _identify(self): + """ + Return the current state of the working directory. + """ + if self.bare: + raise RepositoryError('Bare git repos do not have active branches') + + if self.is_empty(): + return None + + stdout, _ = self.run_git_command(['rev-parse', 'HEAD']) + return stdout.strip() + def _local_clone(self, clone_path, branch_name): """ Create a local clone of the current repo.