aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorAyman Bagabas <ayman.bagabas@gmail.com>2023-04-04 01:13:21 -0400
committerAyman Bagabas <ayman.bagabas@gmail.com>2023-04-17 17:43:46 -0400
commit9a5b08f5c32bad31a35a53c045ebf6c8409f8b2c (patch)
treeef6d49278f14de59481e8e49ac8503c309f534c6 /config
parentb154dcce7059e4e02f8798db158b6a76ffc4a63e (diff)
downloadgo-git-9a5b08f5c32bad31a35a53c045ebf6c8409f8b2c.tar.gz
feat(clone): add mirror clone option
Clone remote as a mirror. This fetches all remote refs, implies bare repository, and sets the appropriate configs. Fixes: https://github.com/go-git/go-git/issues/293 Update options.go Co-authored-by: Paulo Gomes <paulo.gomes.uk@gmail.com> Signed-off-by: Ayman Bagabas <ayman.bagabas@gmail.com>
Diffstat (limited to 'config')
-rw-r--r--config/config.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/config/config.go b/config/config.go
index 83629fc..60dfca4 100644
--- a/config/config.go
+++ b/config/config.go
@@ -264,6 +264,7 @@ const (
defaultBranchKey = "defaultBranch"
repositoryFormatVersionKey = "repositoryformatversion"
objectFormat = "objectformat"
+ mirrorKey = "mirror"
// DefaultPackWindow holds the number of previous objects used to
// generate deltas. The value 10 is the same used by git command.
@@ -578,6 +579,8 @@ type RemoteConfig struct {
// URLs the URLs of a remote repository. It must be non-empty. Fetch will
// always use the first URL, while push will use all of them.
URLs []string
+ // Mirror indicates that the repository is a mirror of remote.
+ Mirror bool
// insteadOfRulesApplied have urls been modified
insteadOfRulesApplied bool
@@ -631,6 +634,7 @@ func (c *RemoteConfig) unmarshal(s *format.Subsection) error {
c.Name = c.raw.Name
c.URLs = append([]string(nil), c.raw.Options.GetAll(urlKey)...)
c.Fetch = fetch
+ c.Mirror = c.raw.Options.Get(mirrorKey) == "true"
return nil
}
@@ -663,6 +667,10 @@ func (c *RemoteConfig) marshal() *format.Subsection {
c.raw.SetOption(fetchKey, values...)
}
+ if c.Mirror {
+ c.raw.SetOption(mirrorKey, strconv.FormatBool(c.Mirror))
+ }
+
return c.raw
}