summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprashantsinalkar2019-09-07 23:49:28 +0530
committerprashantsinalkar2019-09-07 23:49:28 +0530
commitd8104a0901a82bb4d924346c2d6479c9b74cbe2c (patch)
tree2c9dbd085a0d5a01a2032b58c1f2379cf837b3fb
parentb410574b3898bfc376095f480001c98b04f08087 (diff)
downloadR_on_Cloud_Web_Interface-d8104a0901a82bb4d924346c2d6479c9b74cbe2c.tar.gz
R_on_Cloud_Web_Interface-d8104a0901a82bb4d924346c2d6479c9b74cbe2c.tar.bz2
R_on_Cloud_Web_Interface-d8104a0901a82bb4d924346c2d6479c9b74cbe2c.zip
added utils
-rw-r--r--website/utils.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/website/utils.py b/website/utils.py
new file mode 100644
index 0000000..a925b80
--- /dev/null
+++ b/website/utils.py
@@ -0,0 +1,27 @@
+import requests
+from urllib.parse import urljoin
+import json
+from hyper.contrib import HTTP20Adapter
+from git import Repo
+from R_on_Cloud.config import MAIN_REPO
+
+
+def get_commits(file_path, main_repo=True):
+ repo_path = MAIN_REPO + file_path
+ """
+ return: list of commits, which affected the files in filepath
+ """
+ repo = Repo(repo_path, search_parent_directories=True)
+ commit_message = []
+ #print(list(repo.iter_commits(paths = file_path)))
+ for commit in list(repo.iter_commits(paths=file_path)):
+ commit_message.append((commit.message, commit.hexsha))
+ return commit_message
+
+
+def get_file(file_path, commit_sha, main_repo=False):
+
+ repo_path = MAIN_REPO + file_path
+ repo = Repo(repo_path, search_parent_directories=True)
+ file_contents = repo.git.show('{}:{}'.format(commit_sha, file_path))
+ return file_contents \ No newline at end of file