Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
32 lines (29 loc) · 1.06 KB

File metadata and controls

32 lines (29 loc) · 1.06 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from git import Repo
from socketsecurity.core import log
import urllib.parse
class Git:
repo: Repo
path: str
def __init__(self, path: str):
self.path = path
self.repo = Repo(path)
assert self.repo
self.head = self.repo.head
self.commit = self.head.commit
self.repo_name = self.repo.remotes.origin.url.split('.git')[0].split('/')[-1]
try:
self.branch = self.head.reference
urllib.parse.unquote(str(self.branch))
except Exception as error:
self.branch = None
log.debug(error)
self.author = self.commit.author
self.commit_sha = self.commit.binsha
self.commit_message = self.commit.message
self.committer = self.commit.committer
self.show_files = self.repo.git.show(self.commit, name_only=True, format="%n").splitlines()
self.changed_files = []
for item in self.show_files:
if item != "":
full_path = f"{self.path}/{item}"
self.changed_files.append(full_path)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.