Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
git-backup
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Alain Takoudjou
git-backup
Commits
f15ba7e0
Commit
f15ba7e0
authored
Jun 29, 2020
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
do not fail if folder ends with .git and is not a git repository
parent
0985ff32
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
3 deletions
+10
-3
git-backup.go
git-backup.go
+7
-1
git-backup_test.go
git-backup_test.go
+2
-2
testdata/1/dir/nongit.git/latest
testdata/1/dir/nongit.git/latest
+1
-0
No files found.
git-backup.go
View file @
f15ba7e0
...
@@ -495,6 +495,12 @@ func cmd_pull_(ctx context.Context, gb *git.Repository, pullspecv []PullSpec) {
...
@@ -495,6 +495,12 @@ func cmd_pull_(ctx context.Context, gb *git.Repository, pullspecv []PullSpec) {
return
nil
return
nil
}
}
folder
,
err
:=
os
.
Stat
(
path
+
"/objects"
)
if
os
.
IsNotExist
(
err
)
||
!
folder
.
IsDir
()
{
// If this is not a git directory, then return
return
nil
}
// git repo - let's pull all refs from it to our backup refs namespace
// git repo - let's pull all refs from it to our backup refs namespace
infof
(
"# git %s
\t
<- %s"
,
prefix
,
path
)
infof
(
"# git %s
\t
<- %s"
,
prefix
,
path
)
refv
,
_
,
err
:=
fetch
(
ctx
,
path
,
alreadyHave
)
refv
,
_
,
err
:=
fetch
(
ctx
,
path
,
alreadyHave
)
...
@@ -1012,7 +1018,7 @@ func cmd_restore_(ctx context.Context, gb *git.Repository, HEAD_ string, restore
...
@@ -1012,7 +1018,7 @@ func cmd_restore_(ctx context.Context, gb *git.Repository, HEAD_ string, restore
// empty - without refs at all, and thus next "git packs restore"
// empty - without refs at all, and thus next "git packs restore"
// step will not be run for it.
// step will not be run for it.
filedir
:=
pathpkg
.
Dir
(
filename
)
filedir
:=
pathpkg
.
Dir
(
filename
)
if
strings
.
HasSuffix
(
file
dir
,
".git
"
)
&&
!
repos_seen
.
Contains
(
filedir
)
{
if
strings
.
HasSuffix
(
file
name
,
".git/HEAD
"
)
&&
!
repos_seen
.
Contains
(
filedir
)
{
infof
(
"# repo %s
\t
-> %s"
,
prefix
,
filedir
)
infof
(
"# repo %s
\t
-> %s"
,
prefix
,
filedir
)
for
_
,
__
:=
range
[]
string
{
"refs/heads"
,
"refs/tags"
,
"objects/pack"
}
{
for
_
,
__
:=
range
[]
string
{
"refs/heads"
,
"refs/tags"
,
"objects/pack"
}
{
err
:=
os
.
MkdirAll
(
filedir
+
"/"
+
__
,
0777
)
err
:=
os
.
MkdirAll
(
filedir
+
"/"
+
__
,
0777
)
...
...
git-backup_test.go
View file @
f15ba7e0
...
@@ -257,8 +257,8 @@ func TestPullRestore(t *testing.T) {
...
@@ -257,8 +257,8 @@ func TestPullRestore(t *testing.T) {
return
err
return
err
}
}
// non *.git/ -- not interesting
// non *.git/
or nongit.git/
-- not interesting
if
!
(
info
.
IsDir
()
&&
strings
.
HasSuffix
(
path
,
".git"
))
{
if
!
(
info
.
IsDir
()
&&
strings
.
HasSuffix
(
path
,
".git"
))
||
strings
.
HasSuffix
(
path
,
"nongit.git"
)
{
return
nil
return
nil
}
}
...
...
testdata/1/dir/nongit.git/latest
0 → 100644
View file @
f15ba7e0
Not a git repos
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment