-
Notifications
You must be signed in to change notification settings - Fork 96
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
1 parent
0354fa7
commit c0450b1
Showing
3 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
grgit-core/src/main/groovy/org/ajoberstar/grgit/operation/RemoteRemoveOp.groovy
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.ajoberstar.grgit.operation | ||
|
||
import java.util.concurrent.Callable | ||
|
||
import org.ajoberstar.grgit.Repository | ||
import org.ajoberstar.grgit.internal.Operation | ||
import org.eclipse.jgit.lib.Config | ||
|
||
/** | ||
* Removes a remote from the repository. | ||
* @see <a href="http://ajoberstar.org/grgit/grgit-remote.html">grgit-remote</a> | ||
* @see <a href="http://git-scm.com/docs/git-remote">git-remote Manual Page</a> | ||
*/ | ||
@Operation('remove') | ||
class RemoteRemoveOp implements Callable<Void> { | ||
|
||
private final Repository repository | ||
|
||
/** | ||
* Name of the remote. | ||
*/ | ||
String name | ||
|
||
RemoteRemoveOp(Repository repo) { | ||
this.repository = repo | ||
} | ||
|
||
@Override | ||
Void call() { | ||
Config config = repository.jgit.repository.config | ||
config.unsetSection("remote", name) | ||
config.save(); | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
grgit-core/src/test/groovy/org/ajoberstar/grgit/operation/RemoveRemoveOpSpec.groovy
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.ajoberstar.grgit.operation | ||
|
||
import org.ajoberstar.grgit.fixtures.SimpleGitOpSpec | ||
|
||
class RemoveRemoveOpSpec extends SimpleGitOpSpec { | ||
def 'remote with given name is removed'() { | ||
given: | ||
grgit.remote.add(name: 'newRemote', url: 'http://fetch.url/') | ||
when: | ||
grgit.remote.remove(name: 'newRemote') | ||
then: | ||
[] == grgit.remote.list() | ||
} | ||
} |