diff options
author | Matt Hart <matthew.hart@linaro.org> | 2015-08-11 17:17:37 +0100 |
---|---|---|
committer | Matt Hart <matthew.hart@linaro.org> | 2015-08-11 17:32:33 +0100 |
commit | 4a678bcbd2ec96c419c6017e54d353490478a5aa (patch) | |
tree | ef5b5b5a67f00a4986b7c952da533c3b1d8ccb9d /check-git-repos.py | |
parent | f30e8af7f52266d8dd89963816c14cc2ccaeaeb5 (diff) |
check-git-repos: more fixes
Ignore the modified time and always check the refs file
call `git show-ref -d` to include deferenced refs as
these are in the refs file
pep8 fix
Print output from update-server-info if it produces any
Change-Id: I2ad925d18f2bc79c5cf0c6f08ab58c41d70e3cd3
Diffstat (limited to 'check-git-repos.py')
-rwxr-xr-x | check-git-repos.py | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/check-git-repos.py b/check-git-repos.py index 88e4d1c..e535396 100755 --- a/check-git-repos.py +++ b/check-git-repos.py @@ -8,10 +8,6 @@ import stat # Root location of git repos GITROOT = "/srv/repositories" -# Max age of the refs file (in minutes) before processing a repo -MAXAGE = 60 -# Process so many repos per invocation -CHUNK = 500 # Export filename EXPORT_FILE = "git-daemon-export-ok" @@ -44,7 +40,7 @@ def get_file_refs(path): def get_git_refs(path): - ret, out = run_command(["git", "show-ref"], path) + ret, out = run_command(["git", "show-ref", "-d"], path) lines = out.split("\n") gitrefs = {} for line in lines: @@ -57,7 +53,7 @@ def get_git_refs(path): def perms_check(file): st_mode = os.stat(file).st_mode mode = stat.S_IFREG | stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | \ - stat.S_IWGRP | stat.S_IROTH + stat.S_IWGRP | stat.S_IROTH if st_mode != mode: log.warn("Permissions wrong for file %s, changing %s=>%s", file, oct(st_mode), oct(mode)) @@ -85,7 +81,7 @@ def check_ref_status(path): log.warn("%s refs file out of date", path) log.debug("difference is: %s", diff) ret, out = update_server_info(path) - if ret != 0: + if ret != 0 or out != "": log.error("error processing %s, exited %i", path, ret) log.error(out) @@ -101,12 +97,7 @@ def process(paths): perms_check(refsfile) perms_check(path+"/objects/info/packs") # check_export_file(path) - modified_time = os.stat(refsfile).st_mtime - current_time = time.time() - earliest_time = current_time - (MAXAGE * 60) - if modified_time < earliest_time: - log.debug("%s mtime was older than %sm", refsfile, MAXAGE) - check_ref_status(path) + check_ref_status(path) if __name__ == '__main__': |