3 from stgit
.commands
.common
import (
6 DirectoryHasRepository
,
8 from stgit
.lib
.git
import clone
9 from stgit
.lib
.stack
import Stack
12 Copyright (C) 2009, Catalin Marinas <catalin.marinas@gmail.com>
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License version 2 as
16 published by the Free Software Foundation.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, see http://www.gnu.org/licenses/.
27 help = 'Make a local clone of a remote repository'
29 usage
= ['<repository> <dir>']
31 Clone a git repository into the local directory <dir> (using
32 linkstg:clone[]) and initialise the local branch "master".
34 This operation is for example suitable to start working using the
35 "tracking branch" workflow (see link:stg[1]). Other means to setup
36 an StGit stack are linkstg:init[] and the '--create' and '--clone'
37 commands of linkstg:branch[].
39 The target directory <dir> will be created by this command, and must
42 args
= ['repo', 'dir']
45 directory
= DirectoryAnywhere()
48 def func(parser
, options
, args
):
49 """Clone the repository into the local dir and initialise the stack."""
51 parser
.error('incorrect number of arguments')
56 if os
.path
.exists(local_dir
):
57 raise CmdException('"%s" exists. Remove it first' % local_dir
)
59 clone(repository
, local_dir
)
61 directory
= DirectoryHasRepository()
63 Stack
.initialise(directory
.repository
)