Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/devbot/utils.py
blob: 28649489fe693266e53fa040ec5bcfe49358bad1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import os
import subprocess

devnull = open("/dev/null", "w")

def get_commit_id(dir):
    orig_cwd = os.getcwd()
    os.chdir(dir)

    try:
        commit_id = subprocess.check_output(["git", "rev-parse", "HEAD"],
                                            stderr=devnull).strip()
    except subprocess.CalledProcessError:
        commit_id = None

    os.chdir(orig_cwd)

    return commit_id