Last active
          May 5, 2021 15:59 
        
      - 
      
- 
        Save thespacedoctor/72d20c21d037028f0dd5ba84f2b80fa1 to your computer and use it in GitHub Desktop. 
    [Sync Github Repo Wikis Between Github and Local Filesystem] #wiki #github #sync
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/usr/local/bin/python | |
| # encoding: utf-8 | |
| """ | |
| github-wiki-sync.py | |
| =========================== | |
| :Summary: | |
| Sync github wikis between mac and github | |
| :Author: | |
| David Young | |
| :Date Created: | |
| November 10, 2015 | |
| """ | |
| ################# GLOBAL IMPORTS #################### | |
| import sys | |
| import os | |
| from subprocess import Popen, PIPE, STDOUT | |
| def main(arguments=None): | |
| """ | |
| *The main function used when ``github-wiki-sync.py`` is run as a single script from the cl* | |
| """ | |
| basePath = "/Users/Dave/Dropbox/notes" | |
| for d in os.listdir(basePath): | |
| if os.path.isdir(os.path.join(basePath, d)): | |
| if d[-5:] == ".wiki": | |
| repoPath = os.path.join(basePath, d) | |
| cmd = """cd %(repoPath)s && git add . && git commit -m 'auto added' && git pull && git push""" % locals() | |
| p = Popen(cmd, stdout=PIPE, stdin=PIPE, shell=True) | |
| output = p.communicate()[0] | |
| print output | |
| return | |
| if __name__ == '__main__': | |
| main() | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment