Skip to content

Commit

Permalink
sahil-sagwekar2652#10 Adding an argument for 'description' of the Git…
Browse files Browse the repository at this point in the history
…Hub repository sahil-sagwekar2652#46

I have the original 'create_repo' script has been shifted to the 'create_repo.py' file which resolves the conflict.
  • Loading branch information
ashvaneetk committed May 30, 2023
1 parent 1d40444 commit 985c517
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
3 changes: 1 addition & 2 deletions scripts/create_repo
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
#!/bin/bash
python create_repo.py "$@"
python create_repo.py <path> <name> [-d DESCRIPTION]
20 changes: 13 additions & 7 deletions scripts/create_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

URL = "https://api.github.com/user/repos"

parser = argparse.ArgumentParser(description='creates a local repository linked with a remote repository') # noqa: E501

parser = argparse.ArgumentParser(description='creates a local repository linked with a remote repository')
parser.add_argument('path',
metavar='PATH',
type=str,
Expand All @@ -21,8 +20,14 @@
metavar='NAME',
type=str,
help='Enter a name for the new repository')
parser.add_argument('-d',
'--description',
metavar='DESCRIPTION',
type=str,
help='Enter a description for the new repository')
args = parser.parse_args()


name = args.name
path = args.path

Expand All @@ -36,13 +41,14 @@

conn = http.client.HTTPSConnection("api.github.com")
payload = json.dumps({
"name": name,
"description": "made with the GitHub API"
"name": name,
"description": args.description # Modify the value here
})

headers = {
'Authorization': f'Bearer {GITHUB_API_TOKEN}',
'Content-Type': 'application/json',
'User-Agent': f'{USERNAME}'
'Authorization': f'Bearer {GITHUB_API_TOKEN}',
'Content-Type': 'application/json',
'User-Agent': f'{USERNAME}'
}

conn.request("POST", "/user/repos", payload, headers)
Expand Down

0 comments on commit 985c517

Please sign in to comment.