Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
57933b9f
Commit
57933b9f
authored
Nov 30, 2017
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validate worktree paths
parent
407ef708
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
+11
-9
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+11
-9
No files found.
lib/gitlab/git/repository.rb
View file @
57933b9f
...
...
@@ -19,6 +19,8 @@ module Gitlab
]
.
freeze
SEARCH_CONTEXT_LINES
=
3
GITALY_INTERNAL_URL
=
'ssh://gitaly/internal.git'
.
freeze
REBASE_WORKTREE_PREFIX
=
'rebase'
.
freeze
SQUASH_WORKTREE_PREFIX
=
'squash'
.
freeze
NoRepository
=
Class
.
new
(
StandardError
)
InvalidBlobName
=
Class
.
new
(
StandardError
)
...
...
@@ -1213,7 +1215,7 @@ module Gitlab
end
def
rebase
(
user
,
rebase_id
,
branch
:,
branch_sha
:,
remote_repository
:,
remote_branch
:)
rebase_path
=
rebase_dir_path
(
rebase_id
)
rebase_path
=
worktree_path
(
REBASE_WORKTREE_PREFIX
,
rebase_id
)
env
=
git_env_for_user
(
user
)
with_worktree
(
rebase_path
,
branch
,
env:
env
)
do
...
...
@@ -1232,11 +1234,11 @@ module Gitlab
end
def
rebase_in_progress?
(
rebase_id
)
fresh_worktree?
(
rebase_dir_path
(
rebase_id
))
fresh_worktree?
(
worktree_path
(
REBASE_WORKTREE_PREFIX
,
rebase_id
))
end
def
squash
(
user
,
squash_id
,
branch
:,
start_sha
:,
end_sha
:,
author
:,
message
:)
squash_path
=
squash_dir_path
(
squash_id
)
squash_path
=
worktree_path
(
SQUASH_WORKTREE_PREFIX
,
squash_id
)
env
=
git_env_for_user
(
user
).
merge
(
'GIT_AUTHOR_NAME'
=>
author
.
name
,
'GIT_AUTHOR_EMAIL'
=>
author
.
email
...
...
@@ -1267,7 +1269,7 @@ module Gitlab
end
def
squash_in_progress?
(
squash_id
)
fresh_worktree?
(
squash_dir_path
(
squash_id
))
fresh_worktree?
(
worktree_path
(
SQUASH_WORKTREE_PREFIX
,
squash_id
))
end
def
gitaly_repository
...
...
@@ -1368,12 +1370,12 @@ module Gitlab
end
end
def
rebase_dir_path
(
id
)
File
.
join
(
path
,
'gitlab-worktree'
,
"rebase-
#{
id
}
"
)
end
def
worktree_path
(
prefix
,
id
)
id
=
id
.
to_s
raise
ArgumentError
,
"worktree id can't be empty"
unless
id
.
present?
raise
ArgumentError
,
"worktree id can't contain slashes "
if
id
.
include?
(
"/"
)
def
squash_dir_path
(
id
)
File
.
join
(
path
,
'gitlab-worktree'
,
"squash-
#{
id
}
"
)
File
.
join
(
path
,
'gitlab-worktree'
,
"
#{
prefix
}
-
#{
id
}
"
)
end
def
git_env_for_user
(
user
)
...
...
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