diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-11-11 16:58:39 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-11-11 16:58:39 +0400 |
commit | 986697a99bde07ea0d7e878f8618f801b6b81a8c (patch) | |
tree | 8123f73e9bda56df2496d15f2985d2c1a1a8dd8f /lib | |
parent | c77d957b365bd023b1dc73b5f5111b4fe262bfbe (diff) |
Refactor Create/Update file context and lib
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/satellite/files/edit_file_action.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/satellite/files/file_action.rb | 7 | ||||
-rw-r--r-- | lib/gitlab/satellite/files/new_file_action.rb | 4 |
3 files changed, 3 insertions, 12 deletions
diff --git a/lib/gitlab/satellite/files/edit_file_action.rb b/lib/gitlab/satellite/files/edit_file_action.rb index 72e12fb077c..3747c6afc48 100644 --- a/lib/gitlab/satellite/files/edit_file_action.rb +++ b/lib/gitlab/satellite/files/edit_file_action.rb @@ -10,9 +10,7 @@ module Gitlab # Returns false if committing the change fails # Returns false if pushing from the satellite to Gitolite failed or was rejected # Returns true otherwise - def commit!(content, commit_message, last_commit) - return false unless can_edit?(last_commit) - + def commit!(content, commit_message) in_locked_and_timed_satellite do |repo| prepare_satellite!(repo) diff --git a/lib/gitlab/satellite/files/file_action.rb b/lib/gitlab/satellite/files/file_action.rb index 4ac53c2cd5a..7c08e292192 100644 --- a/lib/gitlab/satellite/files/file_action.rb +++ b/lib/gitlab/satellite/files/file_action.rb @@ -8,13 +8,6 @@ module Gitlab @file_path = file_path @ref = ref end - - protected - - def can_edit?(last_commit) - current_last_commit = Gitlab::Git::Commit.last_for_path(@project.repository, ref, file_path).sha - last_commit == current_last_commit - end end end end diff --git a/lib/gitlab/satellite/files/new_file_action.rb b/lib/gitlab/satellite/files/new_file_action.rb index 70a5ea219de..97b19809c8d 100644 --- a/lib/gitlab/satellite/files/new_file_action.rb +++ b/lib/gitlab/satellite/files/new_file_action.rb @@ -9,7 +9,7 @@ module Gitlab # Returns false if committing the change fails # Returns false if pushing from the satellite to Gitolite failed or was rejected # Returns true otherwise - def commit!(content, commit_message, file_name) + def commit!(content, commit_message) in_locked_and_timed_satellite do |repo| prepare_satellite!(repo) @@ -17,7 +17,7 @@ module Gitlab repo.git.checkout({raise: true, timeout: true, b: true}, ref, "origin/#{ref}") # update the file in the satellite's working dir - file_path_in_satellite = File.join(repo.working_dir, file_path || '', file_name) + file_path_in_satellite = File.join(repo.working_dir, file_path) File.open(file_path_in_satellite, 'w') { |f| f.write(content) } # add new file |