Permalink
Browse files

Add list repo command and last commit command

  • Loading branch information...
1 parent 69ac063 commit 909df9e4458bd23abf6bf8f8eea3f7bb333b9852 @benmills benmills committed Mar 30, 2012
Showing with 26 additions and 0 deletions.
  1. +22 −0 src/command.erl
  2. +4 −0 src/git_service.erl
View
@@ -301,6 +301,28 @@ commands() -> [
matches = "git",
subcommands = [
#command {
+ matches = "list",
+ description = "list available repos",
+ action = fun(_Sender, _Body) ->
+ git_service:list_repos()
+ end
+ },
+
+ #command {
+ matches = "(last|latest)",
+ description = "Shows the last commit",
+ action = fun(_Sender, Body) ->
+ RepoName = lists:last(string:tokens(Body, " ")),
+ case git_service:get_repo(RepoName) of
+ error ->
+ "I don't know about that git repo or object";
+ RepoUrl ->
+ git_service:show("", RepoUrl)
+ end
+ end
+ },
+
+ #command {
matches = "show",
description = "<repo name/url> <commit>",
action = fun(_Sender, Body) ->
View
@@ -15,6 +15,10 @@ show(Sha, RepoUrl) ->
% Private
+list_repos() ->
+ DefaultRepos = ?app_env(git_repos),
+ string:join(lists:map(fun({Name, _Url}) -> Name end, DefaultRepos), ", ").
+
get_repo(RepoName) ->
DefaultRepos = dict:from_list(?app_env(git_repos)),
case dict:is_key(RepoName, DefaultRepos) of

0 comments on commit 909df9e

Please sign in to comment.