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
Show 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
...
@@ -19,6 +19,8 @@ module Gitlab
]
.
freeze
]
.
freeze
SEARCH_CONTEXT_LINES
=
3
SEARCH_CONTEXT_LINES
=
3
GITALY_INTERNAL_URL
=
'ssh://gitaly/internal.git'
.
freeze
GITALY_INTERNAL_URL
=
'ssh://gitaly/internal.git'
.
freeze
REBASE_WORKTREE_PREFIX
=
'rebase'
.
freeze
SQUASH_WORKTREE_PREFIX
=
'squash'
.
freeze
NoRepository
=
Class
.
new
(
StandardError
)
NoRepository
=
Class
.
new
(
StandardError
)
InvalidBlobName
=
Class
.
new
(
StandardError
)
InvalidBlobName
=
Class
.
new
(
StandardError
)
...
@@ -1213,7 +1215,7 @@ module Gitlab
...
@@ -1213,7 +1215,7 @@ module Gitlab
end
end
def
rebase
(
user
,
rebase_id
,
branch
:,
branch_sha
:,
remote_repository
:,
remote_branch
:)
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
)
env
=
git_env_for_user
(
user
)
with_worktree
(
rebase_path
,
branch
,
env:
env
)
do
with_worktree
(
rebase_path
,
branch
,
env:
env
)
do
...
@@ -1232,11 +1234,11 @@ module Gitlab
...
@@ -1232,11 +1234,11 @@ module Gitlab
end
end
def
rebase_in_progress?
(
rebase_id
)
def
rebase_in_progress?
(
rebase_id
)
fresh_worktree?
(
rebase_dir_path
(
rebase_id
))
fresh_worktree?
(
worktree_path
(
REBASE_WORKTREE_PREFIX
,
rebase_id
))
end
end
def
squash
(
user
,
squash_id
,
branch
:,
start_sha
:,
end_sha
:,
author
:,
message
:)
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
(
env
=
git_env_for_user
(
user
).
merge
(
'GIT_AUTHOR_NAME'
=>
author
.
name
,
'GIT_AUTHOR_NAME'
=>
author
.
name
,
'GIT_AUTHOR_EMAIL'
=>
author
.
email
'GIT_AUTHOR_EMAIL'
=>
author
.
email
...
@@ -1267,7 +1269,7 @@ module Gitlab
...
@@ -1267,7 +1269,7 @@ module Gitlab
end
end
def
squash_in_progress?
(
squash_id
)
def
squash_in_progress?
(
squash_id
)
fresh_worktree?
(
squash_dir_path
(
squash_id
))
fresh_worktree?
(
worktree_path
(
SQUASH_WORKTREE_PREFIX
,
squash_id
))
end
end
def
gitaly_repository
def
gitaly_repository
...
@@ -1368,12 +1370,12 @@ module Gitlab
...
@@ -1368,12 +1370,12 @@ module Gitlab
end
end
end
end
def
rebase_dir_path
(
id
)
def
worktree_path
(
prefix
,
id
)
File
.
join
(
path
,
'gitlab-worktree'
,
"rebase-
#{
id
}
"
)
id
=
id
.
to_s
end
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'
,
"
#{
prefix
}
-
#{
id
}
"
)
File
.
join
(
path
,
'gitlab-worktree'
,
"squash-
#{
id
}
"
)
end
end
def
git_env_for_user
(
user
)
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