I have this small code in a python lambda that is trying to pull down a repo from bitbucket:
import git
def git_clone(username,password):
new_dir = os.getcwd() "/temp/"
os.chdir(new_dir)
GIT_URL = "https://{0}:{1}@bitbucket.org/test-project/test.git".format(username,password)
git.Git(new_dir).clone(GIT_URL)
The git method accepts my username but does not accept my password. My password contains letters, numbers and special chars. i get this error:
URL using bad/illegal format or missing URL
Could this be a formatting issue?
CodePudding user response:
See the documnetation if using bitbucket
git clone "https://x-token-auth:{token}@bitbucket.org/<user_name>/"
or
url = r"https://x-token-auth:{token}@bitbucket.org/<user_name>/"
git clone url
Here is a solution to your problem. I tested it and it works.
#!/usr/bin/env python
import os
def git_clone(password, username):
if password and username:
url_string = r"git clone https://{}:{}@bitbucket.org/{}/test.git".format(username, password, username)
os.system(url_string)
git_clone(username="<username>", password="<password>")
If this solves your problem, don't forget to accept and upvote it as the correct answer