-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
47 additions
and
44 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,19 +132,61 @@ class RepoSet: ObservableObject { | |
|
||
DispatchQueue.main.async { | ||
print("Completed Refresh") | ||
self.items = reloaded | ||
var included: [Repo] = [] | ||
let remainingIDs = Set<String>(self.items.map({ $0.id.uuidString })) | ||
let reloadedToUse = reloaded.filter({ remainingIDs.contains($0.id.uuidString)}) | ||
self.items = reloadedToUse | ||
self.block?() | ||
self.scheduleRefresh(after: 10.0) | ||
} | ||
} | ||
} | ||
|
||
func addRepo() -> Repo { | ||
@discardableResult func addRepo() -> Repo { | ||
let repo = Repo() | ||
items.append(repo) | ||
return repo | ||
} | ||
|
||
@discardableResult func addRepo(name: String, owner: String) -> Repo { | ||
let repo = Repo(name, owner: owner, workflow: "Tests") | ||
items.append(repo) | ||
return repo | ||
} | ||
|
||
func add(fromFolders urls: [URL]) { | ||
if let detector = try? NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue) { | ||
let fm = FileManager.default | ||
for url in urls { | ||
if let enumerator = fm.enumerator(at: url, includingPropertiesForKeys: []) { | ||
while let url = enumerator.nextObject() as? URL { | ||
if url.lastPathComponent == ".git" { | ||
add(fromGitRepo: url, detector: detector) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
func add(fromGitRepo url: URL, detector: NSDataDetector) { | ||
if let config = try? String(contentsOf: url.appendingPathComponent("config")) { | ||
let tweaked = config.replacingOccurrences(of: "[email protected]:", with: "https://github.com/") | ||
let range = NSRange(location: 0, length: tweaked.count) | ||
for result in detector.matches(in: tweaked, options: [], range: range) { | ||
if let url = result.url, url.scheme == "https", url.host == "github.com" { | ||
let name = url.deletingPathExtension().lastPathComponent | ||
let owner = url.deletingLastPathComponent().lastPathComponent | ||
let existing = items.filter({ $0.name == name && $0.owner == owner }) | ||
if existing.count == 0 { | ||
addRepo(name: name, owner: owner) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
func remove(repo: Repo) { | ||
if let index = items.firstIndex(of: repo) { | ||
var updated = items | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
BUILD_NUMBER = 83 | ||
BUILD_COMMIT = edca550422e479763147453346af24f05cc4b559 | ||
BUILD_NUMBER = 84 | ||
BUILD_COMMIT = d62a93d35d4ce01d1a109e15e37cacb6f39744b4 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,49 +64,10 @@ class AppDelegate: AppCommon { | |
|
||
@IBAction func addLocalRepos() { | ||
pickFilesToOpen(types: ["public.folder"]) { urls in | ||
|
||
|
||
let fm = FileManager.default | ||
for url in urls { | ||
if | ||
let detector = try? NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue), | ||
let items = try? fm.contentsOfDirectory(at: url, includingPropertiesForKeys: [], options: []) { | ||
for item in items { | ||
if item.lastPathComponent == ".git" { | ||
print(item.deletingLastPathComponent()) | ||
if let config = try? String(contentsOf: item.appendingPathComponent("config")) { | ||
let tweaked = config.replacingOccurrences(of: "[email protected]:", with: "https://github.com/") | ||
let range = NSRange(location: 0, length: tweaked.count) | ||
for result in detector.matches(in: tweaked, options: [], range: range) { | ||
if let url = result.url, url.scheme == "https", url.host == "github.com" { | ||
let repo = url.deletingPathExtension().lastPathComponent | ||
let owner = url.deletingLastPathComponent().lastPathComponent | ||
self.addRepo(name: repo, owner: owner) | ||
} | ||
} | ||
// let lines = config.split(separator: "\n").filter({ $0.contains("github.com") }) | ||
// for line in lines { | ||
// if line.contains("[email protected]:") { | ||
// let spec = line.split(separator: ":")[1].split(separator: "/") | ||
// self.addRepo(name: String(spec[0]), owner: String(spec[1])) | ||
// } else if line.contains("https://github.com/") { | ||
// let spec = line.split(separator: "/") | ||
// self.addRepo(name: String(spec[3]), owner: String(spec[4])) | ||
// } | ||
// } | ||
} | ||
} | ||
} | ||
} | ||
} | ||
self.repos.add(fromFolders: urls) | ||
} | ||
} | ||
|
||
func addRepo(name: String, owner: String) { | ||
print(name) | ||
print(owner) | ||
} | ||
|
||
class CustomPicker: UIDocumentPickerViewController, UIDocumentPickerDelegate { | ||
typealias Completion = ([URL]) -> Void | ||
|
||
|