Created
November 4, 2012 10:58
-
-
Save RoyXiang/4011338 to your computer and use it in GitHub Desktop.
Revisions
-
Roy Xiang revised this gist
Nov 17, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- import os -
Roy Xiang revised this gist
Jun 19, 2013 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ #! python2 # -*- coding: utf-8 -*- import os @@ -9,7 +9,7 @@ def updateGit(): cwd = os.getcwd() git = os.path.abspath(os.path.join(cwd, '.git')) myURLs = r'https://github.com/RoyXiang/', r'[email protected]:RoyXiang/' if os.path.exists(git): if os.path.isdir(git): config = os.path.join(git, 'config') -
Roy Xiang revised this gist
Dec 15, 2012 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import os import re import subprocess def updateGit(): cwd = os.getcwd() @@ -35,10 +36,10 @@ def updateGit(): if url != None: if not (lines[i][url.start(1):url.end(1)]).startswith(myURLs): if part.group(2) == 'origin': subprocess.call(['git', 'pull']) else: subprocess.call(['git', 'fetch', part.group(2)]) subprocess.call(['git', 'merge', part.group(2) + '/master']) break else: i = i + 1 -
Roy Xiang revised this gist
Dec 15, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ def updateGit(): cwd = os.getcwd() git = os.path.abspath(os.path.join(cwd, '.git')) myURLs = r'https://github.com/RoyXiang/', r'[email protected]:RoyXiang/' if os.path.exists(git): if os.path.isdir(git): -
Roy Xiang revised this gist
Nov 5, 2012 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -28,9 +28,9 @@ def updateGit(): for i in range(len(lines)): part = re.match(r'^\[([\w]+)(?:\s"([^\]]+)")?\]$', lines[i]) if part != None: i = i + 1 if part.group(1) == 'remote': while True: url = re.match(r'^\s*url\s*=\s*([^\s]+)$', lines[i]) if url != None: if not (lines[i][url.start(1):url.end(1)]).startswith(myURLs): @@ -40,10 +40,11 @@ def updateGit(): os.system('git fetch ' + part.group(2)) os.system('git merge ' + part.group(2) + '/master') break else: i = i + 1 elif part.group(1) == 'submodule': url = re.match(r'^\s*url\s*=\s*([^\s]+)$', lines[i]) print 'Entering \"' + part.group(2) + '\"' path = os.path.abspath(os.path.join(cwd, part.group(2))) os.chdir(path) updateGit() -
Roy Xiang revised this gist
Nov 5, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ def updateGit(): cwd = os.getcwd() git = os.path.abspath(os.path.join(cwd, '.git')) myURLs = r'[email protected]:', r'https://github.com/RoyXiang/', r'[email protected]:RoyXiang/' if os.path.exists(git): if os.path.isdir(git): -
Roy Xiang created this gist
Nov 4, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,53 @@ #! python # -*- coding: utf-8 -*- import os import re def updateGit(): cwd = os.getcwd() git = os.path.abspath(os.path.join(cwd, '.git')) myURLs = r'https://github.com/RoyXiang/', r'[email protected]:RoyXiang/' if os.path.exists(git): if os.path.isdir(git): config = os.path.join(git, 'config') else: gitfile = open(git, 'r') for line in gitfile: gitdir = re.match(r'^gitdir\:\s*(.*)$', line) if gitdir != None: config = os.path.join(cwd, line[gitdir.start(1):gitdir.end(1)], 'config') break config = os.path.abspath(config) else: print 'This is not a git foler!' return lines = open(config, 'r').readlines() for i in range(len(lines)): part = re.match(r'^\[([\w]+)(?:\s"([^\]]+)")?\]$', lines[i]) if part != None: if part.group(1) == 'remote': while True: i = i + 1 url = re.match(r'^\s*url\s*=\s*([^\s]+)$', lines[i]) if url != None: if not (lines[i][url.start(1):url.end(1)]).startswith(myURLs): if part.group(2) == 'origin': os.system('git pull') else: os.system('git fetch ' + part.group(2)) os.system('git merge ' + part.group(2) + '/master') break elif part.group(1) == 'submodule': i = i + 1 url = re.match(r'^\s*url\s*=\s*([^\s]+)$', lines[i]) print 'Entering \'' + part.group(2) + '\'' path = os.path.abspath(os.path.join(cwd, part.group(2))) os.chdir(path) updateGit() os.chdir(cwd) if __name__ == '__main__': updateGit()