9
9
join_path,
10
10
join_path_native,
11
11
to_native_path_linux,
12
- assure_directory_exists
12
+ assure_directory_exists,
13
+ hex_to_bin,
14
+ LockedFD
13
15
)
14
16
from gitdb.exc import (
15
17
BadObject,
16
18
BadName
17
19
)
18
- from gitdb.util import (
19
- join,
20
- dirname,
21
- isdir,
22
- exists,
23
- isfile,
24
- rename,
25
- hex_to_bin,
26
- LockedFD
27
- )
28
20
29
21
import os.path as osp
30
22
@@ -83,7 +75,7 @@ def abspath(self):
83
75
84
76
@classmethod
85
77
def _get_packed_refs_path(cls, repo):
86
- return join(repo.git_dir, 'packed-refs')
78
+ return osp. join(repo.git_dir, 'packed-refs')
87
79
88
80
@classmethod
89
81
def _iter_packed_refs(cls, repo):
@@ -136,7 +128,7 @@ def _get_ref_info(cls, repo, ref_path):
136
128
point to, or None"""
137
129
tokens = None
138
130
try:
139
- with open(join(repo.git_dir, ref_path), 'rt') as fp:
131
+ with open(osp. join(repo.git_dir, ref_path), 'rt') as fp:
140
132
value = fp.read().rstrip()
141
133
# Don't only split on spaces, but on whitespace, which allows to parse lines like
142
134
# 60b64ef992065e2600bfef6187a97f92398a9144 branch 'master' of git-server:/path/to/repo
@@ -420,8 +412,8 @@ def delete(cls, repo, path):
420
412
or just "myreference", hence 'refs/' is implied.
421
413
Alternatively the symbolic reference to be deleted"""
422
414
full_ref_path = cls.to_full_path(path)
423
- abs_path = join(repo.git_dir, full_ref_path)
424
- if exists(abs_path):
415
+ abs_path = osp. join(repo.git_dir, full_ref_path)
416
+ if osp. exists(abs_path):
425
417
os.remove(abs_path)
426
418
else:
427
419
# check packed refs
@@ -472,14 +464,14 @@ def _create(cls, repo, path, resolve, reference, force, logmsg=None):
472
464
corresponding object and a detached symbolic reference will be created
473
465
instead"""
474
466
full_ref_path = cls.to_full_path(path)
475
- abs_ref_path = join(repo.git_dir, full_ref_path)
467
+ abs_ref_path = osp. join(repo.git_dir, full_ref_path)
476
468
477
469
# figure out target data
478
470
target = reference
479
471
if resolve:
480
472
target = repo.rev_parse(str(reference))
481
473
482
- if not force and isfile(abs_ref_path):
474
+ if not force and osp. isfile(abs_ref_path):
483
475
target_data = str(target)
484
476
if isinstance(target, SymbolicReference):
485
477
target_data = target.path
@@ -546,9 +538,9 @@ def rename(self, new_path, force=False):
546
538
if self.path == new_path:
547
539
return self
548
540
549
- new_abs_path = join(self.repo.git_dir, new_path)
550
- cur_abs_path = join(self.repo.git_dir, self.path)
551
- if isfile(new_abs_path):
541
+ new_abs_path = osp. join(self.repo.git_dir, new_path)
542
+ cur_abs_path = osp. join(self.repo.git_dir, self.path)
543
+ if osp. isfile(new_abs_path):
552
544
if not force:
553
545
# if they point to the same file, its not an error
554
546
with open(new_abs_path, 'rb') as fd1:
@@ -563,12 +555,12 @@ def rename(self, new_path, force=False):
563
555
os.remove(new_abs_path)
564
556
# END handle existing target file
565
557
566
- dname = dirname(new_abs_path)
567
- if not isdir(dname):
558
+ dname = osp. dirname(new_abs_path)
559
+ if not osp. isdir(dname):
568
560
os.makedirs(dname)
569
561
# END create directory
570
562
571
- rename(cur_abs_path, new_abs_path)
563
+ os. rename(cur_abs_path, new_abs_path)
572
564
self.path = new_path
573
565
574
566
return self
0 commit comments