Support repositories without .git extension

Julien LepillerWed Aug 25 14:21:39+0200 2021

52fbae6

Support repositories without .git extension

gitile/handler.scm

121121
      (show content #:code 500))
122122
    (define (get-repo name)
123123
      (let ((repo (string-append (config-repositories config)
124-
                                 "/" name ".git")))
125-
        (pk 'repo repo)
126-
        (pk 'exists (file-exists? (string-append repo "/git-daemon-export-ok")))
127-
        (if (file-exists? (string-append repo "/git-daemon-export-ok"))
128-
            (repository-open repo)
129-
            #f)))
124+
                                 "/" name ".git"))
125+
            (repo2 (string-append (config-repositories config)
126+
                                  "/" name)))
127+
        (cond
128+
          ((file-exists? (string-append repo "/git-daemon-export-ok"))
129+
           (repository-open repo))
130+
          ((file-exists? (string-append repo2 "/git-daemon-export-ok"))
131+
           (repository-open repo2))
132+
          (else #f))))
130133
  
131134
    (let ((repo (get-repo project-name)))
132135
      (if repo

157160
            res
158161
            (if (and
159162
                  (> (string-length repo) 4)
160-
                  (equal? (substring repo (- (string-length repo) 4)) ".git")
163+
                  (file-exists? (string-append (config-repositories config)
164+
                                               "/" repo "/.git"))
161165
                  (file-exists? (string-append (config-repositories config)
162166
                                               "/" repo "/git-daemon-export-ok")))
163167
                (loop
164168
                  (cons
165-
                    (name->project (substring repo 0 (- (string-length repo) 4)))
169+
                    (name->project
170+
                      (if (equal? (substring repo (- (string-length repo) 4)) ".git")
171+
                          (substring repo 0 (- (string-length repo) 4))
172+
                          repo))
166173
                    res)
167174
                  (readdir dir))
168175
                (loop res (readdir dir)))))))