Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
git-project
***********

.. image:: https://travis-ci.org/3ptscience/git-project.svg?branch=master&branch=master
:target: https://travis-ci.org/3ptscience/git-project
.. image:: https://travis-ci.org/aranzgeo/git-project.svg?branch=master&branch=master
:target: https://travis-ci.org/aranzgeo/git-project

Scripts extending git for better project and sub-repository management

Expand Down Expand Up @@ -74,4 +74,4 @@ Bugs
----

If you run into any problems with `git-project`, please make an
`issue <https://github.com/3ptscience/git-project/issues>`_
`issue <https://github.com/aranzgeo/git-project/issues>`_
52 changes: 51 additions & 1 deletion git-project
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ else:

MODE = argv[1]

if MODE not in ['init', 'save', 'load', 'status']:
if MODE not in ['init', 'save', 'load', 'status', 'retarget']:
usage(1)


Expand Down Expand Up @@ -187,6 +187,8 @@ for line in lines:
subrepo_info[info[0]]['branch'] = info[1].strip()
subrepo_info[info[0]]['commit'] = info[2].strip()



# ------------------------------------------------------------------------
# init case

Expand All @@ -206,6 +208,54 @@ if MODE == 'init':
else:
print 'repo already exists!'

elif MODE == 'retarget':

target_changes = False
for repo in subrepos:
res = subprocess.check_output(
'cd {dir} && git remote -v'.format(dir=repo),
shell=True,
)
name, remote, action = next(
(line.split() for line in res.split('\n') if line and line.split()[0] == 'origin')
)
if subrepo_info[repo]['remote'] != remote:
subrepo_info[repo]['current_remote'] = remote
target_changes = True

if target_changes:
print 'Some repository targets have changed:'
for repo in subrepos:
if 'current_remote' in subrepo_info[repo]:
print '{repo}: {current} --> {new}'.format(
repo=repo,
current=subrepo_info[repo]['current_remote'],
new=subrepo_info[repo]['remote'],
)

print 'Would you like to update to the new targets? [y/n/q] '
update = sys.stdin.read(1)
if update == 'q':
finish(0)
elif update == 'y':
for repo in subrepos:
if 'current_remote' in subrepo_info[repo]:
print '\t{}...'.format(repo)
if subprocess.call(
'cd {} && git remote set-url origin {}'.format(
repo,
subrepo_info[repo]['remote'],
),
shell=True,
) != 0:
print('Something went wrong changing the remote for {}!'.format(repo))
finish(0)
subrepo_info[repo].pop('current_remote')
print

else:
print 'There are no repositories that need to be re-targeted'

elif MODE == 'status':

print 'TO BE IMPLEMENTED'
Expand Down