Spaces:
Runtime error
Runtime error
Delete entry_with_update.py
Browse files- entry_with_update.py +0 -46
entry_with_update.py
DELETED
|
@@ -1,46 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import sys
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
root = os.path.dirname(os.path.abspath(__file__))
|
| 6 |
-
sys.path.append(root)
|
| 7 |
-
os.chdir(root)
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
try:
|
| 11 |
-
import pygit2
|
| 12 |
-
pygit2.option(pygit2.GIT_OPT_SET_OWNER_VALIDATION, 0)
|
| 13 |
-
|
| 14 |
-
repo = pygit2.Repository(os.path.abspath(os.path.dirname(__file__)))
|
| 15 |
-
|
| 16 |
-
branch_name = repo.head.shorthand
|
| 17 |
-
|
| 18 |
-
remote_name = 'origin'
|
| 19 |
-
remote = repo.remotes[remote_name]
|
| 20 |
-
|
| 21 |
-
remote.fetch()
|
| 22 |
-
|
| 23 |
-
local_branch_ref = f'refs/heads/{branch_name}'
|
| 24 |
-
local_branch = repo.lookup_reference(local_branch_ref)
|
| 25 |
-
|
| 26 |
-
remote_reference = f'refs/remotes/{remote_name}/{branch_name}'
|
| 27 |
-
remote_commit = repo.revparse_single(remote_reference)
|
| 28 |
-
|
| 29 |
-
merge_result, _ = repo.merge_analysis(remote_commit.id)
|
| 30 |
-
|
| 31 |
-
if merge_result & pygit2.GIT_MERGE_ANALYSIS_UP_TO_DATE:
|
| 32 |
-
print("Already up-to-date")
|
| 33 |
-
elif merge_result & pygit2.GIT_MERGE_ANALYSIS_FASTFORWARD:
|
| 34 |
-
local_branch.set_target(remote_commit.id)
|
| 35 |
-
repo.head.set_target(remote_commit.id)
|
| 36 |
-
repo.checkout_tree(repo.get(remote_commit.id))
|
| 37 |
-
repo.reset(local_branch.target, pygit2.GIT_RESET_HARD)
|
| 38 |
-
print("Fast-forward merge")
|
| 39 |
-
elif merge_result & pygit2.GIT_MERGE_ANALYSIS_NORMAL:
|
| 40 |
-
print("Update failed - Did you modify any file?")
|
| 41 |
-
except Exception as e:
|
| 42 |
-
print('Update failed.')
|
| 43 |
-
print(str(e))
|
| 44 |
-
|
| 45 |
-
print('Update succeeded.')
|
| 46 |
-
from launch import *
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|