Class: RepositoriesController
  
  
  
Overview
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  
  #_include_layout?, accept_api_auth, #accept_api_auth?, accept_rss_auth, #accept_rss_auth?, #api_key_from_request, #api_offset_and_limit, #api_request?, #api_switch_user_from_request, #authorize, #authorize_global, #autologin_cookie_name, #back_url, #check_if_login_required, #check_password_change, #check_project_privacy, #deny_access, #filename_for_content_disposition, #find_attachments, #find_current_user, #find_issue, #find_issues, #find_model_object, #find_optional_project, #find_optional_project_by_id, #find_project, #find_project_by_project_id, #find_project_from_association, #handle_unverified_request, #logged_user=, #logout_user, #missing_template, model_object, #parse_params_for_bulk_update, #parse_qvalues, #per_page_option, #query_statement_invalid, #redirect_back_or_default, #redirect_to_referer_or, #render_403, #render_404, #render_api_errors, #render_api_head, #render_api_ok, #render_attachment_warning_if_needed, #render_error, #render_feed, #render_validation_errors, #require_admin, #require_admin_or_api_request, #require_login, #session_expiration, #session_expired?, #set_localization, #start_user_session, #try_to_autologin, #use_layout, #user_setup, #verify_authenticity_token
  
  
  
  
  
  
  
  
  
  #process_sudo_form, #render_sudo_form, #require_sudo_mode, #sudo_mode, #sudo_timestamp_valid?, #update_sudo_timestamp!
  
  
  
  
  
  
  
  
  
  
  #current_menu, #current_menu_item, #menu_items, #redirect_to_menu_item, #redirect_to_project_menu_item
  
  
  
  
  
  
  
  
  
  #default_search_scope, #default_search_scopes
  
  
  
  
  
  
  
  
  
  #_new_project_issue_path, #_new_time_entry_path, #_project_calendar_path, #_project_gantt_path, #_project_issues_path, #_project_news_path, #_report_time_entries_path, #_time_entries_path, #board_path
  
  
  
  
  
  
  
  
  
  #call_hook
  
  
  
  
  
  
  
  
  
  #paginate, #paginator
  
  
  
  
  
  
  
  
  
  #current_language, #day_letter, #day_name, #find_language, #format_date, #format_hours, #format_time, #l, #l_hours, #l_hours_short, #l_or_humanize, #languages_options, #ll, #lu, #month_name, #set_language_if_valid, #valid_languages
  
  
    Instance Method Details
    
      
  
  
    
Adds a related issue to a changeset POST
/projects/:project_id/repository/(:repository_id/)revisions/:rev/issues
   
 
  
    | 
215
216
217
218
219
220
221
222
223
224
225 | # File 'app/controllers/repositories_controller.rb', line 215
def add_related_issue
  issue_id = params[:issue_id].to_s.sub(/^#/,'')
  @issue = @changeset.find_referenced_issue_by_id(issue_id)
  if @issue && (!@issue.visible? || @changeset.issues.include?(@issue))
    @issue = nil
  end
  if @issue
    @changeset.issues << @issue
  end
end | 
 
    
      
  
  
    #annotate  ⇒ Object 
  
  
  
  
    | 
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204 | # File 'app/controllers/repositories_controller.rb', line 185
def annotate
  @entry = @repository.entry(@path, @rev)
  (show_error_not_found; return) unless @entry
  @annotate = @repository.scm.annotate(@path, @rev)
  if @annotate.nil? || @annotate.empty?
    @annotate = nil
    @error_message = l(:error_scm_annotate)
  else
    ann_buf_size = 0
    @annotate.lines.each do |buf|
      ann_buf_size += buf.size
    end
    if ann_buf_size > Setting.file_max_size_displayed.to_i.kilobyte
      @annotate = nil
      @error_message = l(:error_scm_annotate_big_text_file)
    end
  end
  @changeset = @repository.find_changeset_by_name(@rev)
end | 
 
    
      
  
  
    #changes  ⇒ Object 
  
  
  
  
    | 
101
102
103
104
105
106
107 | # File 'app/controllers/repositories_controller.rb', line 101
def changes
  @entry = @repository.entry(@path, @rev)
  (show_error_not_found; return) unless @entry
  @changesets = @repository.latest_changesets(@path, @rev, Setting.repository_log_display_limit.to_i)
  @properties = @repository.properties(@path, @rev)
  @changeset = @repository.find_changeset_by_name(@rev)
end | 
 
    
      
  
  
    #committers  ⇒ Object 
  
  
  
  
    | 
63
64
65
66
67
68
69
70
71
72
73
74
75
76 | # File 'app/controllers/repositories_controller.rb', line 63
def committers
  @committers = @repository.committers
  @users = @project.users.to_a
  additional_user_ids = @committers.collect(&:last).collect(&:to_i) - @users.collect(&:id)
  @users += User.where(:id => additional_user_ids).to_a unless additional_user_ids.empty?
  @users.compact!
  @users.sort!
  if request.post? && params[:committers].present?
        @repository.committer_ids = params[:committers].values.inject({}) {|h, c| h[c.first] = c.last; h}
    flash[:notice] = l(:notice_successful_update)
    redirect_to settings_project_path(@project, :tab => 'repositories')
  end
end | 
 
    
      
  
  
    #create  ⇒ Object 
  
  
  
  
    | 
43
44
45
46
47
48
49 | # File 'app/controllers/repositories_controller.rb', line 43
def create
  if @repository.save
    redirect_to settings_project_path(@project, :tab => 'repositories')
  else
    render :action => 'new'
  end
end | 
 
    
      
  
  
    #destroy  ⇒ Object 
  
  
  
  
    | 
78
79
80
81 | # File 'app/controllers/repositories_controller.rb', line 78
def destroy
  @repository.destroy if request.delete?
  redirect_to settings_project_path(@project, :tab => 'repositories')
end | 
 
    
      
  
  
    #diff  ⇒ Object 
  
  
  
  
    | 
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265 | # File 'app/controllers/repositories_controller.rb', line 236
def diff
  if params[:format] == 'diff'
    @diff = @repository.diff(@path, @rev, @rev_to)
    (show_error_not_found; return) unless @diff
    filename = "changeset_r#{@rev}"
    filename << "_r#{@rev_to}" if @rev_to
    send_data @diff.join, :filename => "#{filename}.diff",
                          :type => 'text/x-patch',
                          :disposition => 'attachment'
  else
    @diff_type = params[:type] || User.current.pref[:diff_type] || 'inline'
    @diff_type = 'inline' unless %w(inline sbs).include?(@diff_type)
        if User.current.logged? && @diff_type != User.current.pref[:diff_type]
      User.current.pref[:diff_type] = @diff_type
      User.current.preference.save
    end
    @cache_key = "repositories/diff/#{@repository.id}/" +
                    Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}-#{current_language}")
    unless read_fragment(@cache_key)
      @diff = @repository.diff(@path, @rev, @rev_to)
      show_error_not_found unless @diff
    end
    @changeset = @repository.find_changeset_by_name(@rev)
    @changeset_to = @rev_to ? @repository.find_changeset_by_name(@rev_to) : nil
    @diff_format_revisions = @repository.diff_format_revisions(@changeset, @changeset_to)
  end
end | 
 
    
      
  
  
    #edit  ⇒ Object 
  
  
  
  
    | 
51
52 | # File 'app/controllers/repositories_controller.rb', line 51
def edit
end | 
 
    
      
  
  
    #entry  ⇒ Object 
  
  
  
  
    | 
130
131
132 | # File 'app/controllers/repositories_controller.rb', line 130
def entry
  entry_and_raw(false)
end | 
 
    
      
  
  
    #graph  ⇒ Object 
  
  
  
  
    
Returns JSON data for repository graphs
   
 
  
    | 
271
272
273
274
275
276
277
278
279
280
281
282
283
284 | # File 'app/controllers/repositories_controller.rb', line 271
def graph
  data = nil
  case params[:graph]
  when "commits_per_month"
    data = graph_commits_per_month(@repository)
  when "commits_per_author"
    data = graph_commits_per_author(@repository)
  end
  if data
    render :json => data
  else
    render_404
  end
end | 
 
    
      
  
  
    #new  ⇒ Object 
  
  
  
  
    | 
39
40
41 | # File 'app/controllers/repositories_controller.rb', line 39
def new
  @repository.is_default = @project.repository.nil?
end | 
 
    
      
  
  
    #raw  ⇒ Object 
  
  
  
  
    | 
126
127
128 | # File 'app/controllers/repositories_controller.rb', line 126
def raw
  entry_and_raw(true)
end | 
 
    
      
  
  
    
Removes a related issue from a changeset DELETE
/projects/:project_id/repository/(:repository_id/)revisions/:rev/issues/:issue_id
   
 
  
    | 
229
230
231
232
233
234 | # File 'app/controllers/repositories_controller.rb', line 229
def remove_related_issue
  @issue = Issue.visible.find_by_id(params[:issue_id])
  if @issue
    @changeset.issues.delete(@issue)
  end
end | 
 
    
      
  
  
    #revision  ⇒ Object 
  
  
  
  
    | 
206
207
208
209
210
211 | # File 'app/controllers/repositories_controller.rb', line 206
def revision
  respond_to do |format|
    format.html
    format.js {render :layout => false}
  end
end | 
 
    
      
  
  
    #revisions  ⇒ Object 
  
  
  
  
    | 
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124 | # File 'app/controllers/repositories_controller.rb', line 109
def revisions
  @changeset_count = @repository.changesets.count
  @changeset_pages = Paginator.new @changeset_count,
                                   per_page_option,
                                   params['page']
  @changesets = @repository.changesets.
    limit(@changeset_pages.per_page).
    offset(@changeset_pages.offset).
    includes(:user, :repository, :parents).
    to_a
  respond_to do |format|
    format.html { render :layout => false if request.xhr? }
    format.atom { render_feed(@changesets, :title => "#{@project.name}: #{l(:label_revision_plural)}") }
  end
end | 
 
    
      
  
  
    #show  ⇒ Object 
  
  
    Also known as:
    browse
    
  
  
  
    | 
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97 | # File 'app/controllers/repositories_controller.rb', line 83
def show
  @repository.fetch_changesets if @project.active? && Setting.autofetch_changesets? && @path.empty?
  @entries = @repository.entries(@path, @rev)
  @changeset = @repository.find_changeset_by_name(@rev)
  if request.xhr?
    @entries ? render(:partial => 'dir_list_content') : head(200)
  else
    (show_error_not_found; return) unless @entries
    @changesets = @repository.latest_changesets(@path, @rev)
    @properties = @repository.properties(@path, @rev)
    @repositories = @project.repositories
    render :action => 'show'
  end
end | 
 
    
      
  
  
    #stats  ⇒ Object 
  
  
  
  
    | 
267
268 | # File 'app/controllers/repositories_controller.rb', line 267
def stats
end | 
 
    
      
  
  
    #update  ⇒ Object 
  
  
  
  
    | 
54
55
56
57
58
59
60
61 | # File 'app/controllers/repositories_controller.rb', line 54
def update
  @repository.safe_attributes = params[:repository]
  if @repository.save
    redirect_to settings_project_path(@project, :tab => 'repositories')
  else
    render :action => 'edit'
  end
end |