File tree Expand file tree Collapse file tree
Open diff view settings
Expand file tree Collapse file tree
Open diff view settings
Original file line number Diff line number Diff line change 1+ # -*- coding: utf-8 -*-
2+ # This module is part of GitPython and is released under
3+ # the BSD License: http://www.opensource.org/licenses/bsd-license.php
4+
5+ from pathlib import Path
6+ import re
7+
8+ import git
9+
10+ from .lib import (
11+ TestBase ,
12+ with_rw_directory ,
13+ )
14+
15+ class TestClone (TestBase ):
16+ @with_rw_directory
17+ def test_checkout_in_non_empty_dir (self , rw_dir ):
18+ non_empty_dir = Path (rw_dir )
19+ garbage_file = non_empty_dir / 'not-empty'
20+ garbage_file .write_text ('Garbage!' )
21+
22+ # Verify that cloning into the non-empty dir fails while complaining about the target directory not being empty/non-existent
23+ try :
24+ self .rorepo .clone (non_empty_dir )
25+ except git .GitCommandError as exc :
26+ self .assertTrue (exc .stderr , "GitCommandError's 'stderr' is unexpectedly empty" )
27+ expr = re .compile (r'(?is).*\bfatal:\s+destination\s+path\b.*\bexists\b.*\bnot\b.*\bempty\s+directory\b' )
28+ self .assertTrue (expr .search (exc .stderr ), '"%s" does not match "%s"' % (expr .pattern , exc .stderr ))
29+ else :
30+ self .fail ("GitCommandError not raised" )
You can’t perform that action at this time.
0 commit comments