File: add-github-dev.ml

package info (click to toggle)
opam 2.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,500 kB
  • sloc: ml: 61,414; sh: 2,963; ansic: 1,147; makefile: 479; sed: 6; csh: 1
file content (31 lines) | stat: -rwxr-xr-x 931 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env opam-admin.top
#directory "+../opam-lib";;
open Opam_admin_top;;

#use "topfind";;
#require "re";;

let github_re =
  Re.compile (Re_perl.re "([^/]*github.com/.*)/archive/.*");;

iter_packages_gen @@ fun nv ~prefix:_ ~opam ~descr:_ ~url ~dot_install:_ ->
let opam =
  if OpamFile.OPAM.dev_repo opam <> None then opam else
    match url with
    | None -> opam
    | Some u ->
      let url = OpamFile.URL.url u in
      if url.OpamUrl.backend = `http &&
         Re.execp github_re url.OpamUrl.path then
        let substrings = Re.exec github_re url.OpamUrl.path in
        let dev_url =
          { OpamUrl.transport = "git";
            path = Re.get substrings 1;
            hash = None;
            backend = `git }
        in
        let opam = OpamFile.OPAM.with_dev_repo opam dev_url in
        OpamFile.OPAM.with_opam_version opam (OpamVersion.of_string "1.2")
      else opam
in
opam, `Keep, `Keep, `Keep