简体   繁体   中英

How can I update an existing file in a github repo with python without cloning the repo down?

hope you can help me with this one.. A simple example will do.. I have a Mule project in a github repo and I need to update the pom.xml automatically.. I know could "mimic" what we humans do with python3 by cloning the repo down, update the file and push the changes back to github.. (using the "os" module) but In this case I cannot clone the repo..(the storage is not reliable) I see that there are several github modules for python I cant get it to work (lack of knowledge I guess).. If anyone can show me simply how to update a line in the file (replace a string for example).. that would be a great starting point for me.

sample scenario: file: https://github.com/USERNAME/PROJECT_NAME/blob/master/pom.xml

I need to update line <artifactId>template</artifactId> (in this case, line 6) with the line <artifactId>actual_project_name</artifactId>

Thanks!

I was able to "crack it"... (just needed time and try/error)

I shared a simple script to do basic tasks using the pyGithub module, included partially update a file. Hopefully this will help anyone on the same situation and will be a nice starting point. cheers!!

REPO LINK: https://github.com/santiagomoneta/pygithub-example

Cheers!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM