Search code examples
ruby-on-railsgitgitolite

Howto publish a git repository with ruby as zipfile


I am using OpenProject as project management software and I am not very familiar with ruby and rails, but using the gitolite-plugin works quite well.

I am looking for a solution to provide a link to the OpenProject users where they can directly download the gitolite-hosted repository as a zipfile.

Is that possible ?

I am willing to put pieces of code together, so even partially solutions and hints are welcome. thx.


Solution

  • Nothing in oliverguenther/openproject-revisions_git would do a :

    You would need to extend that plugin in order to expose that feature, implementing a ruby function to call git-archive on the right project, a bit like in this gist:

    (extract)

      # Runs the `git archive` command to pull your repository out 
      # into a tar or tar.gz and writes it to a temporary directory
      #
      # Args:
      # * path - path within the repository to archive, defaults to the root
      #
      # Returns the path to the tar file
      def archive(path=nil)
        @archive_path = path || ''
        create_tmp_directory
        @tar_path = "#{@tmp_directory_path}/archive.tar#{@gzip}"
        Dir.chdir @path
        puts "Archived repository" if run_shell_cmd "git archive --prefix=#{@archive_path}/ #{@branch}:#{@archive_path} -o #{@tar_path}" and @verbose
        Dir.chdir @pwd
        @tar_path
    end