Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push to remote URL and git logging added #91

Merged
merged 2 commits into from
Oct 18, 2018
Merged

Conversation

alichtman
Copy link
Owner

Bug in git_set_remote that has to be fixed before this can be merged.

def git_set_remote(repo, remote_url):
	"""
	Sets git repo upstream URL and fast-forwards history.
	TODO: Allow users to name the remote.
	"""
	print(Fore.GREEN + Style.BRIGHT + "Setting remote URL to {}...".format(remote_url) + Style.RESET_ALL)
	remotes = [remote for remote in repo.remotes]
	# pprint([remote.url for remote in remotes])
	# Repo has no remotes, just create a new remote and pull.
	if len(remotes) == 0:
		origin = create_remote(repo, remote_url)
		if not repo.head:
			repo.create_head('master', origin.refs.master)
		repo.heads.master.set_tracking_branch(origin.refs.master).checkout()
		origin.fetch()
	# Update push URL with new URL.
	else:
		# TODO: Fix this error that fails a push after updating the URL:
		# 		"There is no tracking information for the current branch."
		repo.delete_remote(repo.remotes.origin)
		origin = create_remote(repo, remote_url)
		repo.heads.master.set_tracking_branch(origin.refs.master).checkout()
		origin.fetch()

@alichtman alichtman mentioned this pull request Oct 18, 2018
3 tasks
@alichtman alichtman merged commit ee885f6 into master Oct 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant