File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright 2019 The Gogs Authors. All rights reserved.
2
+ // Use of this source code is governed by a MIT-style
3
+ // license that can be found in the LICENSE file.
4
+
5
+ package git
6
+
7
+ import "strings"
8
+
9
+ // RemoveRemote removes a remote from given repository path if exists.
10
+ func RemoveRemote (repoPath , remote string ) error {
11
+ _ , err := NewCommand ("remote" , "rm" , remote ).RunInDir (repoPath )
12
+ if err != nil && ! strings .Contains (err .Error (), "fatal: No such remote" ) {
13
+ return err
14
+ }
15
+ return nil
16
+ }
17
+
18
+ // AddRemoteOptions contains options to add a remote address.
19
+ type AddRemoteOptions struct {
20
+ Mirror bool
21
+ }
22
+
23
+ // AddRemote adds a new remote
24
+ func AddRemote (repoPath , remote , addr string , opts AddRemoteOptions ) error {
25
+ cmd := NewCommand ("remote" , "add" , remote )
26
+ if opts .Mirror {
27
+ cmd .AddArguments ("--mirror" )
28
+ }
29
+ _ , err := cmd .AddArguments (addr ).RunInDir (repoPath )
30
+ return err
31
+ }
You can’t perform that action at this time.
0 commit comments