text stringlengths 0 828 |
|---|
Returns: |
str -- relative path of the current dir to git root dir |
empty string if current dir is the git root dir |
"""""" |
repo = Repo() |
current_dir = os.getcwd() |
repo_dir = repo.tree().abspath |
delta_dir = current_dir.replace(repo_dir, '') |
if delta_dir: |
return delta_dir + '/' |
else: |
return ''" |
3931,"def commit(filename): |
""""""Commit (git) a specified file |
This method does the same than a :: |
$ git commit -a ""message"" |
Keyword Arguments: |
:filename: (str) -- name of the file to commit |
Returns: |
<nothing> |
"""""" |
try: |
repo = Repo() |
# gitcmd = repo.git |
# gitcmd.commit(filename) |
index = repo.index |
index.commit(""Updated file: {0}"".format(filename)) |
except Exception as e: |
print(""exception while commit: %s"" % e.message)" |
3932,"def add_file_to_repo(filename): |
""""""Add a file to the git repo |
This method does the same than a :: |
$ git add filename |
Keyword Arguments: |
:filename: (str) -- name of the file to commit |
Returns: |
<nothing> |
"""""" |
try: |
repo = Repo() |
index = repo.index |
index.add([_delta_dir() + filename]) |
except Exception as e: |
print(""exception while gitadding file: %s"" % e.message)" |
3933,"def reset_to_last_commit(): |
""""""reset a modified file to his last commit status |
This method does the same than a :: |
$ git reset --hard |
Keyword Arguments: |
<none> |
Returns: |
<nothing> |
"""""" |
try: |
repo = Repo() |
gitcmd = repo.git |
gitcmd.reset(hard=True) |
except Exception: |
pass" |
3934,"def commit_history(filename): |
""""""Retrieve the commit history for a given filename. |
Keyword Arguments: |
:filename: (str) -- full name of the file |
Returns: |
list of dicts -- list of commit |
if the file is not found, returns an empty list |
"""""" |
result = [] |
repo = Repo() |
for commit in repo.head.commit.iter_parents(paths=_delta_dir() + filename): |
result.append({'date': |
datetime.fromtimestamp(commit.committed_date + |
commit.committer_tz_offset), |
'hexsha': commit.hexsha}) |
return result" |
3935,"def read_committed_file(gitref, filename): |
""""""Retrieve the content of a file in an old commit and returns it. |
Ketword Arguments: |
:gitref: (str) -- full reference of the git commit |
:filename: (str) -- name (full path) of the file |
Returns: |
str -- content of the file |
"""""" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.