Skip to content

Instantly share code, notes, and snippets.

@gochist
Last active March 25, 2024 19:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gochist/8654460717b4bbb4ac490dda79a547fa to your computer and use it in GitHub Desktop.
Save gochist/8654460717b4bbb4ac490dda79a547fa to your computer and use it in GitHub Desktop.
import os
import subprocess
DEVNULL = open(os.devnull, 'w')
BASE_CONTENT = "content/en"
WORK_CONTENT = "content/ko"
L_COMMIT = "website/dev-1.13-ko.3"
R_COMMIT = "website/master"
def get_changed_contents(l_commit, r_commit):
strip_index = len(BASE_CONTENT)+1
cmd = ["git", "diff", l_commit, r_commit, "--name-only", "--", BASE_CONTENT]
changed_files = subprocess.check_output(cmd).decode("UTF-8").splitlines()
ret = [f[strip_index:] for f in changed_files]
return ret
def git_diff(filepath):
cmd = ["git", "diff", L_COMMIT, R_COMMIT, "--shortstat", "--", os.path.join(BASE_CONTENT, filepath)]
return subprocess.check_output(cmd).decode("UTF-8")
def git_exists(path, filepath):
cmd = ["git", "cat-file", "-e", "{}:{}".format(path, filepath)]
ret_code = subprocess.call(cmd, stderr=DEVNULL)
return ret_code == 0
if __name__ == "__main__":
changed_contents = get_changed_contents(L_COMMIT, R_COMMIT)
outdated_contents = [f for f in changed_contents if git_exists(R_COMMIT, os.path.join(WORK_CONTENT, f))]
print("{} files in {} are changed".format(len(changed_contents), BASE_CONTENT))
print("{} files in {} are outdated".format(len(outdated_contents), WORK_CONTENT))
if outdated_contents:
print()
for c in outdated_contents:
print("- [ ] ", c, git_diff(c).strip())
@gochist
Copy link
Author

gochist commented Aug 26, 2018

output example

400 files in content/en are changed
23 files in content/ko are outdated

  • docs/concepts/overview/what-is-kubernetes.md 1 file changed, 1 insertion(+), 1 deletion(-)
  • docs/concepts/workloads/_index.md 1 file changed, 1 insertion(+), 1 deletion(-)
  • docs/concepts/workloads/pods/pod-overview.md 1 file changed, 2 insertions(+), 2 deletions(-)
  • docs/home/_index.md 1 file changed, 1 insertion(+)
  • docs/reference/_index.md 1 file changed, 3 insertions(+)
  • docs/setup/minikube.md 1 file changed, 51 insertions(+), 41 deletions(-)
  • docs/setup/multiple-zones.md 1 file changed, 3 insertions(+), 1 deletion(-)
  • docs/setup/pick-right-solution.md 1 file changed, 7 insertions(+), 4 deletions(-)
  • docs/setup/scratch.md 1 file changed, 4 insertions(+), 6 deletions(-)
  • docs/tasks/run-application/horizontal-pod-autoscale-walkthrough.md 1 file changed, 8 insertions(+), 7 deletions(-)
  • docs/tutorials/hello-minikube.md 1 file changed, 157 insertions(+), 336 deletions(-)
  • docs/tutorials/kubernetes-basics/_index.html 1 file changed, 13 insertions(+), 13 deletions(-)
  • docs/tutorials/kubernetes-basics/create-cluster/cluster-interactive.html 1 file changed, 1 insertion(+), 1 deletion(-)
  • docs/tutorials/kubernetes-basics/create-cluster/cluster-intro.html 1 file changed, 1 insertion(+), 1 deletion(-)
  • docs/tutorials/kubernetes-basics/deploy-app/deploy-interactive.html 1 file changed, 1 insertion(+), 1 deletion(-)
  • docs/tutorials/kubernetes-basics/deploy-app/deploy-intro.html 1 file changed, 1 insertion(+), 1 deletion(-)
  • docs/tutorials/kubernetes-basics/explore/explore-interactive.html 1 file changed, 1 insertion(+), 1 deletion(-)
  • docs/tutorials/kubernetes-basics/explore/explore-intro.html 1 file changed, 2 insertions(+), 2 deletions(-)
  • docs/tutorials/kubernetes-basics/expose/expose-interactive.html 1 file changed, 1 insertion(+), 1 deletion(-)
  • docs/tutorials/kubernetes-basics/expose/expose-intro.html 1 file changed, 2 insertions(+), 2 deletions(-)
  • docs/tutorials/kubernetes-basics/scale/scale-interactive.html 1 file changed, 1 insertion(+), 1 deletion(-)
  • docs/tutorials/kubernetes-basics/scale/scale-intro.html 1 file changed, 1 insertion(+), 1 deletion(-)
  • docs/tutorials/kubernetes-basics/update/update-intro.html 1 file changed, 1 insertion(+), 1 deletion(-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment