Created
July 5, 2016 01:55
-
-
Save matthewr6/987542bab715f619a88f3b0b23738836 to your computer and use it in GitHub Desktop.
automatically pull from master for all directories at the same level
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
package main | |
import ( | |
"os" | |
"fmt" | |
"os/exec" | |
"io/ioutil" | |
) | |
func main() { | |
dirs, _ := ioutil.ReadDir("./") | |
for _, dir := range dirs { | |
if dir.IsDir() { | |
dirName := fmt.Sprintf("./%v", dir.Name()) | |
_, err := os.Stat(fmt.Sprintf("%v/.git", dirName)) | |
if err == nil { | |
os.Chdir(dirName) | |
_, err := exec.Command("git", "pull", "origin", "master").Output() | |
if err == nil { | |
fmt.Printf("Successfully pulled master into %v\n", dir.Name()) | |
} else { | |
fmt.Println(err) | |
} | |
os.Chdir("..") | |
} | |
} | |
} | |
} |
Author
matthewr6
commented
Jul 5, 2016
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment