Last active
March 5, 2021 01:40
-
-
Save johndpope/c859925603e8f176318c1d28a1dca6fc to your computer and use it in GitHub Desktop.
test
This file contains 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
// written for MasOSX | |
import Foundation | |
import Alamofire | |
import ShellOut | |
import SwiftyJSON | |
class GitData{ | |
var gitBio : String = "" | |
var gitDescrip : String = "" | |
var gitLogin : String = "" | |
var gitFullName : String = "" | |
var gitName : String = "" | |
var gitRepo : Int = 0 | |
} | |
let semaphore = DispatchSemaphore(value: 0) | |
var repoList = [GitData]() | |
func syncForks(){ | |
let url = "https://api.github.com/users/johndpope/repos?per_page=100" | |
Alamofire.request(url, method: .get).responseJSON { | |
response in | |
if response.result.isSuccess{ | |
print(" **************** Success ****************") | |
let json = JSON(response.result.value!) | |
print(json) | |
processRepo(json: json) | |
}else{ | |
print("Error \(String(describing: response.result.error))") | |
} | |
// syncFork() | |
semaphore.signal() | |
} | |
} | |
func processRepo(json: JSON){ | |
let repos = json[].arrayValue | |
for repo in repos{ | |
if (repo["fork"] == true){ | |
let data = GitData() | |
data.gitName = repo["name"].stringValue | |
data.gitLogin = repo["owner"]["login"].stringValue | |
data.gitDescrip = repo["description"].stringValue | |
data.gitFullName = repo["full_name"].stringValue | |
repoList.append(data) | |
} | |
} | |
} | |
func syncFork(){ | |
do { | |
var output = try shellOut(to: "git", arguments: ["clone https://github.com/pandas-dev/pandas"]) | |
output = try shellOut(to: "cd pandas") | |
output = try shellOut(to: "git remote add upstream https://github.com/pandas-dev/pandas.git") | |
output = try shellOut(to: "git fetch upstream") | |
output = try shellOut(to: "git checkout master") | |
output = try shellOut(to: "git pull upstream master") | |
output = try shellOut(to: "git add -A") | |
output = try shellOut(to: "git commit -m \"Sync upstream master with master branch\"") | |
output = try shellOut(to: "git push origin master") | |
print("output:",output) | |
} catch { | |
let error = error as! ShellOutError | |
print(error.message) // Prints STDERR | |
print(error.output) // Prints STDOUT | |
} | |
} | |
syncForks() | |
semaphore.wait() |
This file contains 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
git clone https://github.com/JohnSundell/Marathon.git | |
cd Marathon | |
make | |
marathon add https://github.com/JohnSundell/ShellOut.git | |
marathon add https://github.com/Alamofire/Alamofire.git | |
marathon add https://github.com/SwiftyJSON/SwiftyJSON.git | |
marathon add https://github.com/apollographql/apollo-ios.git |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment