Can git commit signing implementation be updated to be easier to use?
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- git, ruby
- Área
- backend-api-design, devtools
Línea de trabajo
Empieza leyendo Rugged::Commit.create, create_to_s y create_with_signature; después, sigue cómo se comportan index.write y las actualizaciones de referencias para un repositorio bare nuevo. La tarea estará terminada cuando se pueda crear un commit firmado mediante una única llamada a nivel de Commit con la entrada de firma, preservando el comportamiento normal del índice y de HEAD/las referencias.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Been trying to implement signing of commits in a project we use.
I have sort of gotten it to work but the implementation between a none signed commit and signed commit differs a lot and i would like it to become much easier so the code in the project i use gets cleaner.
Basically this is how we implemented none signed today, it works for a newly created bare repo also.
oid = repo.write("This is a blob.", :blob)
index = repo.index
index.read_tree(repo.head.target.tree)
index.add(:path => "README.md", :oid => oid, :mode => 0100644)
options = {}
options[:tree] = index.write_tree(repo)
options[:author] = { :email => "testuser@github.com", :name => 'Test Author', :time => Time.now }
options[:committer] = { :email => "testuser@github.com", :name => 'Test Author', :time => Time.now }
options[:message] ||= "Making a commit via Rugged!"
options[:parents] = repo.empty? ? [] : [ repo.head.target ].compact
options[:update_ref] = 'HEAD'
@commitref = Rugged::Commit.create(repo, options)
index.write
But to make signed commits in a new bare repo the first part is the same with options but alot after differs.
oid = repo.write("This is a blob.", :blob)
index = repo.index
index.read_tree(repo.head.target.tree)
index.add(:path => "README.md", :oid => oid, :mode => 0100644)
options = {}
options[:tree] = index.write_tree(repo)
options[:author] = { :email => "testuser@github.com", :name => 'Test Author', :time => Time.now }
options[:committer] = { :email => "testuser@github.com", :name => 'Test Author', :time => Time.now }
options[:message] ||= "Making a commit via Rugged!"
options[:parents] = repo.empty? ? [] : [ repo.head.target ].compact
options[:update_ref] = 'HEAD'
# Create a string of the contents to be commited.
content = Rugged::Commit.create_to_s(repo, options)
# Sign the string.
crypto = GPGME::Crypto.new(armor: true)
signature = crypto.detach_sign(content, signers: @cfg.sign_key).to_s.strip
# Create a commit using the string and signature.
@commitref = Rugged::Commit.create_with_signature(repo, content, signature, 'gpgsig')
# After doing this create_with_signature calling for index.write does not work.
# and i have to do this repo references else i cant see any commits when i do git log --show-signature
# Check if HEAD exists and handle accordingly
if repo.references.exist?("HEAD") && !repo.head_unborn?
# HEAD exists and points to a real branch
repo.references.update(repo.head.name, @commitref)
else
# HEAD doesn't exist or is unborn - create default branch
repo.references.create("refs/heads/master", @commitref)
end
I would like the implementation of signed commits to be as easy as doing a normal commit just that i have to specify the key i want to sign with.
e.g
# Just want a function i can call for as easy as Commit.create that signs my commits and update the reference on disk.
Rugged::Commit.commit_with_signature(repo, options, signature)
- Lenguaje dominante
- C
- Estrellas
- 2.3k
- Forks
- 293
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de libgit2/rugged
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 48/100
-
LFS support? Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 20/100
Todos los issues de libgit2/rugged
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
BasedHardware/omi#15662 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
-
level/task module/gcp type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
-
Build failure with newer clang Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
hapostgres/pg_auto_failover#1190 ·
-
docs
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100