Compare commits

...

5 Commits

Author SHA1 Message Date
Jose Diaz-Gonzalez
dd2b96b172 Release version 0.12.1 2017-03-27 14:55:11 -06:00
Jose Diaz-Gonzalez
7a589f1e63 Merge pull request #57 from acdha/reuse-existing-remotes
Avoid remote branch name churn
2017-03-27 14:54:02 -06:00
Chris Adams
92c619cd01 Avoid remote branch name churn
This avoids the backup output having lots of "[new branch]" messages
because removing the old remote name removed all of the existing branch
references.
2017-03-27 16:26:19 -04:00
Jose Diaz-Gonzalez
9a91dd7733 Merge pull request #55 from amaczuga/master
Fix detection of bare git directories
2016-11-22 13:36:52 -07:00
Andrzej Maczuga
6592bd8196 Fix detection of bare git directories 2016-11-22 20:11:26 +00:00
3 changed files with 39 additions and 8 deletions

View File

@@ -1,6 +1,18 @@
Changelog Changelog
========= =========
0.12.1 (2017-03-27)
-------------------
- Avoid remote branch name churn. [Chris Adams]
This avoids the backup output having lots of "[new branch]" messages
because removing the old remote name removed all of the existing branch
references.
- Fix detection of bare git directories. [Andrzej Maczuga]
0.12.0 (2016-11-22) 0.12.0 (2016-11-22)
------------------- -------------------

View File

@@ -714,6 +714,15 @@ def fetch_repository(name,
local_dir, local_dir,
skip_existing=False, skip_existing=False,
bare_clone=False): bare_clone=False):
if bare_clone:
if os.path.exists(local_dir):
clone_exists = subprocess.check_output(['git',
'rev-parse',
'--is-bare-repository'],
cwd=local_dir) == "true\n"
else:
clone_exists = False
else:
clone_exists = os.path.exists(os.path.join(local_dir, '.git')) clone_exists = os.path.exists(os.path.join(local_dir, '.git'))
if clone_exists and skip_existing: if clone_exists and skip_existing:
@@ -732,11 +741,21 @@ def fetch_repository(name,
if clone_exists: if clone_exists:
log_info('Updating {0} in {1}'.format(name, local_dir)) log_info('Updating {0} in {1}'.format(name, local_dir))
remotes = subprocess.check_output(['git', 'remote', 'show'],
cwd=local_dir)
remotes = [i.strip() for i in remotes.decode('utf-8')]
if 'origin' not in remotes:
git_command = ['git', 'remote', 'rm', 'origin'] git_command = ['git', 'remote', 'rm', 'origin']
logging_subprocess(git_command, None, cwd=local_dir) logging_subprocess(git_command, None, cwd=local_dir)
git_command = ['git', 'remote', 'add', 'origin', remote_url] git_command = ['git', 'remote', 'add', 'origin', remote_url]
logging_subprocess(git_command, None, cwd=local_dir) logging_subprocess(git_command, None, cwd=local_dir)
git_command = ['git', 'fetch', '--all', '--tags', '--prune'] else:
git_command = ['git', 'remote', 'set-url', 'origin', remote_url]
logging_subprocess(git_command, None, cwd=local_dir)
git_command = ['git', 'fetch', '--all', '--force', '--tags', '--prune']
logging_subprocess(git_command, None, cwd=local_dir) logging_subprocess(git_command, None, cwd=local_dir)
else: else:
log_info('Cloning {0} repository from {1} to {2}'.format( log_info('Cloning {0} repository from {1} to {2}'.format(
@@ -744,7 +763,7 @@ def fetch_repository(name,
masked_remote_url, masked_remote_url,
local_dir)) local_dir))
if bare_clone: if bare_clone:
git_command = ['git', 'clone', '--bare', remote_url, local_dir] git_command = ['git', 'clone', '--mirror', remote_url, local_dir]
else: else:
git_command = ['git', 'clone', remote_url, local_dir] git_command = ['git', 'clone', remote_url, local_dir]
logging_subprocess(git_command, None) logging_subprocess(git_command, None)

View File

@@ -1 +1 @@
__version__ = '0.12.0' __version__ = '0.12.1'