aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorStanislav Seletskiy <s.seletskiy@gmail.com>2019-06-11 02:33:09 +0300
committerStanislav Seletskiy <s.seletskiy@gmail.com>2019-07-25 16:38:47 +0300
commit5d9007f27b50c17cefecd13ad160840aa4f86ed1 (patch)
tree0c5eb99b444e361a2380b2083f066860cf55212c /config
parent60033b8925a18fff9f68bea3d980076f73eb3cb5 (diff)
downloadgo-git-5d9007f27b50c17cefecd13ad160840aa4f86ed1.tar.gz
add Prune option to PushOptions
Signed-off-by: Stanislav Seletskiy <s.seletskiy@gmail.com>
Diffstat (limited to 'config')
-rw-r--r--config/refspec.go7
-rw-r--r--config/refspec_test.go9
2 files changed, 16 insertions, 0 deletions
diff --git a/config/refspec.go b/config/refspec.go
index 391705c..b2b3203 100644
--- a/config/refspec.go
+++ b/config/refspec.go
@@ -127,6 +127,13 @@ func (s RefSpec) Dst(n plumbing.ReferenceName) plumbing.ReferenceName {
return plumbing.ReferenceName(dst[0:wd] + match + dst[wd+1:])
}
+func (s RefSpec) Reverse() RefSpec {
+ spec := string(s)
+ separator := strings.Index(spec, refSpecSeparator)
+
+ return RefSpec(spec[separator+1:] + refSpecSeparator + spec[:separator])
+}
+
func (s RefSpec) String() string {
return string(s)
}
diff --git a/config/refspec_test.go b/config/refspec_test.go
index 675e075..b925cba 100644
--- a/config/refspec_test.go
+++ b/config/refspec_test.go
@@ -116,6 +116,15 @@ func (s *RefSpecSuite) TestRefSpecDstBlob(c *C) {
"refs/remotes/origin/foo",
)
}
+
+func (s *RefSpecSuite) TestRefSpecReverse(c *C) {
+ spec := RefSpec("refs/heads/*:refs/remotes/origin/*")
+ c.Assert(
+ spec.Reverse(), Equals,
+ RefSpec("refs/remotes/origin/*:refs/heads/*"),
+ )
+}
+
func (s *RefSpecSuite) TestMatchAny(c *C) {
specs := []RefSpec{
"refs/heads/bar:refs/remotes/origin/foo",