Read about our upcoming Code of Conduct on this issue

This instance will be upgraded to Heptapod 0.28.1 on 2022-01-26 at 16:00 UTC+1 (a few minutes of down time)

repository.rb 2.74 KB
Newer Older
1
# All routing related to repository browsing
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
2
3
4

resource :repository, only: [:create] do
  member do
5
    get 'archive', constraints: { format: Gitlab::PathRegex.archive_formats_regex }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
6
7
8
  end
end

9
10
11
12
13
14
15
16
17
# Don't use format parameter as file extension (old 3.0.x behavior)
# See http://guides.rubyonrails.org/routing.html#route-globbing-and-wildcard-segments
scope format: false do
  get '/compare/:from...:to', to: 'compare#show', as: 'compare', constraints: { from: /.+/, to: /.+/ }

  resources :compare, only: [:index, :create] do
    collection do
      get :diff_for_path
    end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
18
19
  end

20
21
22
23
24
25
26
  resources :refs, only: [] do
    collection do
      get 'switch'
    end

    member do
      # tree viewer logs
27
      get 'logs_tree', constraints: { id: Gitlab::PathRegex.git_reference_regex }
28
29
30
31
32
33
34
      # Directories with leading dots erroneously get rejected if git
      # ref regex used in constraints. Regex verification now done in controller.
      get 'logs_tree/*path', action: :logs_tree, as: :logs_file, format: false, constraints: {
        id: /.*/,
        path: /.*/
      }
    end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
35
36
  end

37
  scope constraints: { id: Gitlab::PathRegex.git_reference_regex } do
38
    resources :network, only: [:show]
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
39

40
41
42
43
44
45
46
47
    resources :graphs, only: [:show] do
      member do
        get :charts
        get :commits
        get :ci
        get :languages
      end
    end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
48

49
50
51
52
53
    resources :branches, only: [:index, :new, :create, :destroy]
    delete :merged_branches, controller: 'branches', action: :destroy_all_merged
    resources :tags, only: [:index, :show, :new, :create, :destroy] do
      resource :release, only: [:edit, :update]
    end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
54

55
56
57
58
59
60
61
62
63
64
65
    resources :protected_branches, only: [:index, :show, :create, :update, :destroy]
    resources :protected_tags, only: [:index, :show, :create, :update, :destroy]
  end

  scope constraints: { id: /.+/ }  do
    scope controller: :blob do
      get '/new/*id', action: :new, as: :new_blob
      post '/create/*id', action: :create, as: :create_blob
      get '/edit/*id', action: :edit, as: :edit_blob
      put '/update/*id', action: :update, as: :update_blob
      post '/preview/*id', action: :preview, as: :preview_blob
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
66

67
68
69
70
71
72
73
74
      scope path: '/blob/*id', as: :blob do
        get :diff
        get '/', action: :show
        delete '/', action: :destroy
        post '/', action: :create
        put '/', action: :update
      end
    end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
75

76
77
78
79
    get '/tree/*id', to: 'tree#show', as: :tree
    get '/raw/*id', to: 'raw#show', as: :raw
    get '/blame/*id', to: 'blame#show', as: :blame
    get '/commits/*id', to: 'commits#show', as: :commits
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
80

81
    post '/create_dir/*id', to: 'tree#create_dir', as: :create_dir
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
82

83
84
    scope controller: :find_file do
      get '/find_file/*id', action: :show, as: :find_file
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
85

86
87
88
89
      get '/files/*id', action: :list, as: :files
    end
  end
end