From 3000d9412383326f35b292d51d4d6d684d68d68b Mon Sep 17 00:00:00 2001
From: Vishesh Handa <me@vhanda.in>
Date: Sat, 7 Nov 2020 14:17:41 +0100
Subject: [PATCH] When adding a remote rm the old remote with the same name

This is a problem when setting up the remote fails.
---
 lib/setup/screens.dart | 5 +++++
 pubspec.lock           | 8 ++++----
 pubspec.yaml           | 4 ++--
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/lib/setup/screens.dart b/lib/setup/screens.dart
index d155a564..08358f6f 100644
--- a/lib/setup/screens.dart
+++ b/lib/setup/screens.dart
@@ -502,6 +502,11 @@ class GitHostSetupScreenState extends State<GitHostSetupScreen> {
     String error;
     try {
       var repo = await GitRepository.load(repoPath);
+      var remotes = repo.config.remotes;
+      var i = remotes.indexWhere((r) => r.name == widget.remoteName);
+      if (i != -1) {
+        await repo.removeRemote(widget.remoteName);
+      }
       await repo.addRemote(widget.remoteName, _gitCloneUrl);
 
       var repoN = git_bindings.GitRepo(folderPath: repoPath);
diff --git a/pubspec.lock b/pubspec.lock
index 88734bf2..066fa037 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -181,10 +181,10 @@ packages:
     description:
       path: "."
       ref: HEAD
-      resolved-ref: "071cb643a4924a45986920f44c0e2433ee9159ed"
-      url: "https://github.com/GitJournal/dart_git.git"
+      resolved-ref: b489bbb315e066b332e438747c1359004ff2b244
+      url: "https://github.com/GitJournal/dart-git.git"
     source: git
-    version: "0.0.1"
+    version: "0.0.2"
   device_info:
     dependency: "direct main"
     description:
@@ -1165,5 +1165,5 @@ packages:
     source: hosted
     version: "0.0.9"
 sdks:
-  dart: ">=2.10.0-110 <2.11.0"
+  dart: ">=2.10.1 <2.11.0"
   flutter: ">=1.20.0 <2.0.0"
diff --git a/pubspec.yaml b/pubspec.yaml
index 61a1f141..fd80368d 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -33,8 +33,8 @@ dependencies:
     #path: /Users/vishesh/src/gitjournal/git_bindings
     git: https://github.com/GitJournal/git_bindings.git
   dart_git:
-    git: https://github.com/GitJournal/dart_git.git
-    #path: /Users/vishesh/src/gitjournal/dart_git
+    git: https://github.com/GitJournal/dart-git.git
+    #path: /Users/vishesh/src/gitjournal/dart-git
   yaml_serializer: ^0.0.9
   connectivity: ^0.4.6+1
   flutter_emoji: ">= 2.0.0"