1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-12 11:02:21 -05:00

Added function to auto-update remote origin url, can be manually set in config as well.

This commit is contained in:
echel0n 2014-11-12 16:00:45 -08:00
parent 78b9bb2c8d
commit 88e1f2e65a
2 changed files with 15 additions and 1 deletions

View File

@ -105,6 +105,7 @@ NOTIFY_ON_UPDATE = False
CUR_COMMIT_HASH = None CUR_COMMIT_HASH = None
BRANCH = '' BRANCH = ''
GIT_REMOTE = '' GIT_REMOTE = ''
GIT_REMOTE_URL = ''
CUR_COMMIT_BRANCH = '' CUR_COMMIT_BRANCH = ''
INIT_LOCK = Lock() INIT_LOCK = Lock()
@ -465,7 +466,7 @@ def get_backlog_cycle_time():
def initialize(consoleLogging=True): def initialize(consoleLogging=True):
with INIT_LOCK: with INIT_LOCK:
global BRANCH, GIT_REMOTE, CUR_COMMIT_HASH, CUR_COMMIT_BRANCH, ACTUAL_LOG_DIR, LOG_DIR, WEB_PORT, WEB_LOG, ENCRYPTION_VERSION, WEB_ROOT, WEB_USERNAME, WEB_PASSWORD, WEB_HOST, WEB_IPV6, USE_API, API_KEY, ENABLE_HTTPS, HTTPS_CERT, HTTPS_KEY, \ global BRANCH, GIT_REMOTE, GIT_REMOTE_URL, CUR_COMMIT_HASH, CUR_COMMIT_BRANCH, ACTUAL_LOG_DIR, LOG_DIR, WEB_PORT, WEB_LOG, ENCRYPTION_VERSION, WEB_ROOT, WEB_USERNAME, WEB_PASSWORD, WEB_HOST, WEB_IPV6, USE_API, API_KEY, ENABLE_HTTPS, HTTPS_CERT, HTTPS_KEY, \
HANDLE_REVERSE_PROXY, USE_NZBS, USE_TORRENTS, NZB_METHOD, NZB_DIR, DOWNLOAD_PROPERS, CHECK_PROPERS_INTERVAL, ALLOW_HIGH_PRIORITY, TORRENT_METHOD, \ HANDLE_REVERSE_PROXY, USE_NZBS, USE_TORRENTS, NZB_METHOD, NZB_DIR, DOWNLOAD_PROPERS, CHECK_PROPERS_INTERVAL, ALLOW_HIGH_PRIORITY, TORRENT_METHOD, \
SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, SAB_HOST, \ SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, SAB_HOST, \
NZBGET_USERNAME, NZBGET_PASSWORD, NZBGET_CATEGORY, NZBGET_PRIORITY, NZBGET_HOST, NZBGET_USE_HTTPS, backlogSearchScheduler, \ NZBGET_USERNAME, NZBGET_PASSWORD, NZBGET_CATEGORY, NZBGET_PRIORITY, NZBGET_HOST, NZBGET_USE_HTTPS, backlogSearchScheduler, \
@ -538,6 +539,7 @@ def initialize(consoleLogging=True):
# git_remote # git_remote
GIT_REMOTE = check_setting_str(CFG, 'General', 'git_remote', 'origin') GIT_REMOTE = check_setting_str(CFG, 'General', 'git_remote', 'origin')
GIT_REMOTE_URL = check_setting_str(CFG, 'General', 'git_remote_url', 'https://github.com/SiCKRAGETV/SickRage.git')
# current commit hash # current commit hash
CUR_COMMIT_HASH = check_setting_str(CFG, 'General', 'cur_commit_hash', '') CUR_COMMIT_HASH = check_setting_str(CFG, 'General', 'cur_commit_hash', '')
@ -1368,6 +1370,7 @@ def save_config():
new_config['General'] = {} new_config['General'] = {}
new_config['General']['branch'] = BRANCH new_config['General']['branch'] = BRANCH
new_config['General']['git_remote'] = GIT_REMOTE new_config['General']['git_remote'] = GIT_REMOTE
new_config['General']['git_remote_url'] = GIT_REMOTE_URL
new_config['General']['cur_commit_hash'] = CUR_COMMIT_HASH new_config['General']['cur_commit_hash'] = CUR_COMMIT_HASH
new_config['General']['cur_commit_branch'] = CUR_COMMIT_BRANCH new_config['General']['cur_commit_branch'] = CUR_COMMIT_BRANCH
new_config['General']['config_version'] = CONFIG_VERSION new_config['General']['config_version'] = CONFIG_VERSION

View File

@ -442,6 +442,9 @@ class GitUpdateManager(UpdateManager):
self._num_commits_behind = 0 self._num_commits_behind = 0
self._num_commits_ahead = 0 self._num_commits_ahead = 0
# update remote origin url
self.update_remote_origin()
# get all new info from github # get all new info from github
output, err, exit_status = self._run_git(self._git_path, 'fetch %s' % sickbeard.GIT_REMOTE) output, err, exit_status = self._run_git(self._git_path, 'fetch %s' % sickbeard.GIT_REMOTE)
@ -537,6 +540,9 @@ class GitUpdateManager(UpdateManager):
on the call's success. on the call's success.
""" """
# update remote origin url
self.update_remote_origin()
if self.branch == self._find_installed_branch(): if self.branch == self._find_installed_branch():
output, err, exit_status = self._run_git(self._git_path, 'pull -f %s %s' % (sickbeard.GIT_REMOTE, self.branch)) # @UnusedVariable output, err, exit_status = self._run_git(self._git_path, 'pull -f %s %s' % (sickbeard.GIT_REMOTE, self.branch)) # @UnusedVariable
else: else:
@ -553,11 +559,16 @@ class GitUpdateManager(UpdateManager):
return False return False
def list_remote_branches(self): def list_remote_branches(self):
# update remote origin url
self.update_remote_origin()
branches, err, exit_status = self._run_git(self._git_path, 'ls-remote --heads %s' % sickbeard.GIT_REMOTE) # @UnusedVariable branches, err, exit_status = self._run_git(self._git_path, 'ls-remote --heads %s' % sickbeard.GIT_REMOTE) # @UnusedVariable
if exit_status == 0 and branches: if exit_status == 0 and branches:
return re.findall('\S+\Wrefs/heads/(.*)', branches) return re.findall('\S+\Wrefs/heads/(.*)', branches)
return [] return []
def update_remote_origin(self):
self._run_git(self._git_path, 'config remote.origin.url %s' % sickbeard.GIT_REMOTE_URL)
class SourceUpdateManager(UpdateManager): class SourceUpdateManager(UpdateManager):
def __init__(self): def __init__(self):