diff mbox

[kteam-tools] ktl: Git.config() allows 'git config' queries

Message ID 1369433163-17314-1-git-send-email-kamal@canonical.com
State New
Headers show

Commit Message

Kamal Mostafa May 24, 2013, 10:06 p.m. UTC
API interface to 'git config'.

Examples:

    print Git.config("user.email")
    kamal@canonical.com

    print Git.config("remote.origin.url")
    git://kernel.ubuntu.com/ubuntu/kteam-tools.git

Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 ktl/git.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Brad Figg May 28, 2013, 3:52 p.m. UTC | #1
On 05/24/2013 03:06 PM, Kamal Mostafa wrote:
> API interface to 'git config'.
> 
> Examples:
> 
>     print Git.config("user.email")
>     kamal@canonical.com
> 
>     print Git.config("remote.origin.url")
>     git://kernel.ubuntu.com/ubuntu/kteam-tools.git
> 
> Signed-off-by: Kamal Mostafa <kamal@canonical.com>
> ---
>  ktl/git.py | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/ktl/git.py b/ktl/git.py
> index 48abc99..9483ad4 100644
> --- a/ktl/git.py
> +++ b/ktl/git.py
> @@ -39,6 +39,17 @@ class Git:
>  
>          return retval
>  
> +    # config
> +    #
> +    # Return the requested git config value. E.g. config("user.email")
> +    #
> +    @classmethod
> +    def config(cls, key):
> +        status, result = run_command("git config %s" % key, cls.debug)
> +        if status != 0:
> +            raise GitError(result)
> +        return result[0]
> +
>      # branches
>      #
>      # Return a list of all the git branches known to this git repository.
> 

New functionality, no chance of regressions.
diff mbox

Patch

diff --git a/ktl/git.py b/ktl/git.py
index 48abc99..9483ad4 100644
--- a/ktl/git.py
+++ b/ktl/git.py
@@ -39,6 +39,17 @@  class Git:
 
         return retval
 
+    # config
+    #
+    # Return the requested git config value. E.g. config("user.email")
+    #
+    @classmethod
+    def config(cls, key):
+        status, result = run_command("git config %s" % key, cls.debug)
+        if status != 0:
+            raise GitError(result)
+        return result[0]
+
     # branches
     #
     # Return a list of all the git branches known to this git repository.