rugged icon indicating copy to clipboard operation
rugged copied to clipboard

Config doesn't handle getting and storing all types of attributes

Open bdunne opened this issue 8 years ago • 3 comments

Hello, I'm working on transitioning my project over to using rugged. I'm amazed at the performance improvements that we've seen so far. I'm getting down to the last few operations that need to be converted and I'm stuck on this one:

I want to add a second fetch for a remote.

My desired config looks like this:

[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[remote "origin"]
	url = [email protected]:ManageIQ/manageiq.git
	fetch = +refs/heads/*:refs/remotes/origin/*
	fetch = +refs/pull/*:refs/prs/*
[branch "master"]
	remote = origin
	merge = refs/heads/master

In order to achieve this, I need to first read the config looking for the fetches, but I get the following which doesn't show the first fetch:

Rugged::Repository.new(my_path).config.get("remote.origin.fetch")
=> "+refs/pull/*:refs/prs/*"

I can work around this with:

Rugged::Repository.new(my_path).remotes.first.fetch_refspecs
=> ["+refs/heads/*:refs/remotes/origin/*", "+refs/pull/*:refs/prs/*"]

I can achieve this on the command line with

$ git config --get-all "remote.origin.fetch"
+refs/heads/*:refs/remotes/origin/*
+refs/pull/*:refs/prs/*

Then I want to add the second ref and store it if it doesn't already exist, but store and []= blow up with:

Rugged::Repository.new(my_path).config.store("remote.origin.fetch", "+refs/pull/*:refs/prs/*")
Rugged::ConfigError: multivar incompatible with simple set

I can achieve this on the command line with:

git config --add remote.origin.fetch +refs/pull/*:refs/prs/*

Is there another way to store this in the config?

bdunne avatar Nov 29 '17 21:11 bdunne

Hello @tenderlove I was looking through the list of committers on this project and saw your name. Can you take a look at this or suggest someone else to start the discussion?

Thanks! Hope all is well and happy holidays!

bdunne avatar Dec 21 '17 17:12 bdunne

Hey @bdunne! Good to hear from you. I've been looking in to this, but I don't see a way from the gem to get multiple configuration values out, so I added get_all in #737. I'll see if I can figure out something for a multi-value set.

tenderlove avatar Jan 19 '18 03:01 tenderlove

Thanks for looking into it @tenderlove

bdunne avatar Jan 19 '18 04:01 bdunne