Skip to content

Commit ad47935

Browse files
committed
improvements in contribute feature
1 parent ec607da commit ad47935

5 files changed

Lines changed: 19 additions & 48 deletions

File tree

.github/workflows/pull_request.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

contribute

100644100755
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
# Check if the first 3 arguments are provided
4-
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
4+
if [ -z $1 ] || [ -z $2 ] || [ -z $3 ]; then
55
echo "Error: The first 3 arguments are mandatory."
66
echo "Usage: ./contribute <Study-Name> <Full-Path-To-Study> <Author-Name> <Branch-Name> <PR-title> <PR-Body>"
77
exit 1
@@ -11,13 +11,13 @@ fi
1111
arg4=$4
1212
arg5=$5
1313
arg6=$6
14-
if [ -z "$4" ]; then
14+
if [ -z $4 ]; then
1515
arg4="#"
1616
fi
17-
if [ -z "$5" ]; then
17+
if [ -z $5 ]; then
1818
arg5="#"
1919
fi
20-
if [ -z "$6" ]; then
20+
if [ -z $6 ]; then
2121
arg6="#"
2222
fi
23-
python contribute.py $1 $2 $3 $arg4 $arg5 $arg6
23+
python3 contribute.py $1 $2 $3 $arg4 $arg5 $arg6

contribute.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@
44

55
# Intializing the Variables
66
# Hashed token
7-
BOT_TOKEN = 'Z2l0aHViX3BhdF8xMUFYS0pGVFkwUWVWZ3AzbkpkWk8yX3BOc1VncDFIVDMwZVNXcHhBNm9acHhMaGZGdU5CdE85TGpqdXF1UWRRNzI2S01aUk5HRUNGanFWNDZi'
8-
REPO_NAME = 'concore' #repo name
7+
BOT_TOKEN = 'Z2l0aHViX3BhdF8xMUFYS0pGVFkwd2xwT0dmYldFOTBBXzN3Nkx2THpiaUFKek5pTDdqNlpLUzVwUUpoTlJWR3dtNnM0NWNDa0RmWTJaTTZLSUpHRHhERlhrZlJS'
8+
REPO_NAME = 'concore-studies' #repo name
99
OWNER_NAME = 'parteekcoder123' #bot account name
1010
STUDY_NAME = sys.argv[1]
1111
STUDY_NAME_PATH = sys.argv[2]
1212
AUTHOR_NAME = sys.argv[3]
1313
BRANCH_NAME = sys.argv[4]
1414
PR_TITLE = sys.argv[5]
1515
PR_BODY = sys.argv[6]
16-
UPSTREAM_OWNER = 'parteekcoder' # upstream to which examples should be contributed
17-
16+
UPSTREAM_OWNER = 'ControlCore-Project' # upstream to which examples should be contributed
1817

1918
# Defining Functions
2019
def checkInputValidity():
@@ -77,9 +76,9 @@ def fetchUpstream(repo,base_sha,branch):
7776
def runWorkflow(repo,upstream_repo):
7877
openPR = anyOpenPR(upstream_repo)
7978
if openPR==None:
80-
workflow_runned = repo.get_workflow(id_or_name="pull_request.yml").create_dispatch(ref=BRANCH_NAME,inputs={'title':PR_TITLE,'body':PR_BODY,'upstreamRepo':upstream_repo,'botRepo':OWNER_NAME,'repo':REPO_NAME})
79+
workflow_runned = repo.get_workflow(id_or_name="pull_request.yml").create_dispatch(ref=BRANCH_NAME,inputs={'title':PR_TITLE,'body':PR_BODY,'upstreamRepo':UPSTREAM_OWNER,'botRepo':OWNER_NAME,'repo':REPO_NAME})
8180
if not workflow_runned:
82-
print("Some Error Occured.Please try after some time")
81+
print("Some error occured.Please try after some time")
8382
exit(0)
8483
else:
8584
printPRStatus(upstream_repo)
@@ -105,10 +104,10 @@ def isImageFile(filename):
105104
return file_extension.lower() in image_extensions
106105

107106
# Encode Github Token
108-
def encode_token(token):
109-
encoded_bytes = base64.b64encode(token.encode('utf-8'))
110-
encoded_token = encoded_bytes.decode('utf-8')
111-
return encoded_token
107+
# def encode_token(token):
108+
# encoded_bytes = base64.b64encode(token.encode('utf-8'))
109+
# encoded_token = encoded_bytes.decode('utf-8')
110+
# return encoded_token
112111

113112

114113
# Decode Github Token

fri/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ Flask
22
gunicorn==20.1.0
33
FLASK_CORS
44
jupyterlab
5+
PyGithub

fri/server/main.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,10 @@ def contribute():
182182
if(platform.uname()[0]=='Windows'):
183183
proc=check_output(["contribute",STUDY_NAME,STUDY_NAME_PATH,AUTHOR_NAME,BRANCH_NAME,PR_TITLE,PR_BODY],cwd=concore_path,shell=True)
184184
else:
185-
proc = check_output(["./contribute",STUDY_NAME,STUDY_NAME_PATH,AUTHOR_NAME,BRANCH_NAME,PR_TITLE,PR_BODY],cwd=concore_path)
185+
if len(BRANCH_NAME)==0:
186+
proc = check_output(["./contribute",STUDY_NAME,STUDY_NAME_PATH,AUTHOR_NAME],cwd=concore_path)
187+
else:
188+
proc = check_output(["./contribute",STUDY_NAME,STUDY_NAME_PATH,AUTHOR_NAME,BRANCH_NAME,PR_TITLE,PR_BODY],cwd=concore_path)
186189
output_string = proc.decode()
187190
status=200
188191
if output_string.find("/pulls/")!=-1:
@@ -193,7 +196,6 @@ def contribute():
193196
status=400
194197
return jsonify({'message': output_string}),status
195198
except Exception as e:
196-
print(e)
197199
output_string = "Some Error occured.Please try after some time"
198200
status=501
199201
return jsonify({'message': output_string}),status

0 commit comments

Comments
 (0)