Update changelog for recent commits
[stgit.git] / stgit / commands / id.py
blob929613619e364aecfa4a14673d858edb3e2b01a1
1 from stgit.commands.common import DirectoryHasRepository, git_commit
2 from stgit.out import out
4 __copyright__ = """
5 Copyright (C) 2005, Catalin Marinas <catalin.marinas@gmail.com>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 2 as
9 published by the Free Software Foundation.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see http://www.gnu.org/licenses/.
18 """
20 help = 'Print the git hash value of a StGit reference'
21 kind = 'repo'
22 usage = ['[options] [--] [<id>]']
23 description = r"""
24 Print the SHA1 value of a Git id (defaulting to HEAD). In addition to the
25 standard Git id's like heads and tags, this command also accepts
26 '[<branch>:]<patch>' for the id of a patch and '[<branch>:]\{base\}' for the
27 base of the stack. If no branch is specified, it defaults to the current one.
28 The bottom of a patch is accessible with the '[<branch>:]<patch>^' format."""
30 args = ['applied_patches', 'unapplied_patches', 'hidden_patches']
31 options = []
33 directory = DirectoryHasRepository()
36 def func(parser, options, args):
37 """Show the applied patches"""
38 if len(args) == 0:
39 id_str = 'HEAD'
40 elif len(args) == 1:
41 id_str = args[0]
42 else:
43 parser.error('incorrect number of arguments')
45 out.stdout(git_commit(id_str, directory.repository).sha1)