Skip to content

Commit

Permalink
Merge pull request #103 from parteekcoder/contribute_action
Browse files Browse the repository at this point in the history
Update contribute.py
  • Loading branch information
pradeeban authored Aug 6, 2023
2 parents c97416f + 438d328 commit 2ac3e87
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions contribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def commitAndUpdateRef(repo,tree_content,commit,branch):


def appendBlobInTree(repo,content,file_path,tree_content):
blob = repo.create_git_blob(content,'utf-8')
blob = repo.create_git_blob(content,'ascii')
tree_content.append( github.InputGitTreeElement(path=file_path,mode="100644",type="blob",sha=blob.sha))


Expand Down Expand Up @@ -106,7 +106,6 @@ def decode_token(encoded_token):
decoded_bytes = encoded_token.encode("ascii")
convertedbytes = base64.b64decode(decoded_bytes)
decoded_token = convertedbytes.decode("ascii")
print('token decoded successfully')
return decoded_token


Expand Down Expand Up @@ -155,23 +154,20 @@ def decode_token(encoded_token):
for root, dirs, files in os.walk(STUDY_NAME_PATH):
for filename in files:
path = f"{root}/{filename}"
print(path)
if isImageFile(filename):
with open(path, 'rb') as file:
with open(file=path, mode='rb') as file:
image = file.read()
print('image processing')
content = base64.b64encode(image).decode('utf-8')
else:
with open(path, 'r') as file:
with open(file=path, mode='r',encoding='ascii') as file:
content = file.read()
file_path = f'{DIR_PATH+remove_prefix(path,STUDY_NAME_PATH)}'
if(platform.uname()[0]=='Windows'): file_path=file_path.replace("\\","/")
print(path)
print('d',end="")
appendBlobInTree(repo,content,file_path,tree_content)
print('append comp')
commitAndUpdateRef(repo,tree_content,base_ref.commit,branch)
print('comit comp')
runWorkflow(repo,upstream_repo)
print('work comp')
except Exception as e:
print(e)
print("Some error Occured.Please try again after some time.",end="")
Expand Down

0 comments on commit 2ac3e87

Please sign in to comment.