# # patch "git.ml" # from [d46a4993e5167aea7e5a1d5e2bee71f7f00ae859] # to [1a02999ff418b308b65af1f90f0cc4776339a298] # # patch "main.ml" # from [0ff0e7377579201a776760f2ecff06dc8879035c] # to [c4252b62386dbca252641e1cca98cb4509ccc0b3] # --- git.ml +++ git.ml @@ -18,10 +18,23 @@ git_kind : [`LINUS|`PASKY] ; head : id ; get_commit : (string -> commit) ; - get_changeset : (string -> changeset) + get_changeset : (string -> changeset) ; + tags : (string * string) list ; } +let id_of_file ?dir f = + with_file_in + input_line + (match dir with None -> f | Some d -> Filename.concat d f) +let fetch_tags git_dir = + try + let tags_dir = Filename.concat git_dir "tags" in + List.map + (fun t -> (id_of_file ~dir:tags_dir t, t)) + (Array.to_list (Sys.readdir tags_dir)) + with _ -> [] + let fetch_history base id = log "exec" "### exec: Running rev-tree %s'" id ; match Gspawn.sync @@ -190,16 +203,15 @@ let d, kind = if Sys.file_exists ds then ds, `PASKY else if Sys.file_exists dl then dl, `LINUS else failwith "unknown" in - let head = - string_slice ~e:(-1) - (with_file_in input_channel (Filename.concat d "HEAD")) in + let head = id_of_file ~dir:d "HEAD" in let get_commit = Viz_misc.make_cache (get_commit_object db_name) in let get_changeset = Viz_misc.make_cache (get_changeset kind db_name get_commit) in { base = db_name ; git_kind = kind ; head = head ; get_commit = get_commit ; - get_changeset = get_changeset } + get_changeset = get_changeset ; + tags = fetch_tags d } with Failure _ | Sys_error _ -> Viz_types.errorf "Not a git db: %s" db_name @@ -224,10 +236,15 @@ c_name = "" ; c_value = "" ; c_signer_id = "" ; c_signature = SIG_OK } in let c = d.get_commit id in - { (fetch_revision d id) with certs = [ - { fake_cert with c_name = "author" ; c_value = c.author } ; - { fake_cert with c_name = "committer" ; c_value = c.committer } ; - { fake_cert with c_name = "changelog" ; c_value = c.log } ] + let cert_list = + try + let tag = List.assoc id d.tags in + [ { fake_cert with c_name = "tag" ; c_value = tag } ] + with Not_found -> [] in + { (fetch_revision d id) with certs = + { fake_cert with c_name = "author" ; c_value = c.author } :: + { fake_cert with c_name = "committer" ; c_value = c.committer } :: + { fake_cert with c_name = "changelog" ; c_value = c.log } :: cert_list } (* for autocolor by keyid *) @@ -239,10 +256,17 @@ let a = (d.get_commit id).author in try Scanf.sscanf a "%s@>" (fun id -> id) with _ -> a ] + | "tag" -> begin + try [ List.assoc id d.tags ] + with Not_found -> [] + end | _ -> [] (* find by tag *) -let get_matching_tags d p = [] +let get_matching_tags d p = + List.filter + (fun (_, t) -> p t) + d.tags (* find by date *) let get_matching_dates d s = [] --- main.ml +++ main.ml @@ -36,7 +36,7 @@ let main = let w = GWindow.window - ~title:"Monotone-viz" + ~title:"git-viz" ~icon:(Lazy.force Icon.monotone) () in ignore (w#connect#destroy GMain.quit) ;