I am trying to remove one of the objects from a gitlab array of several commits.
[
{
:commit=>#<Git: :Object: :Commit: @base=#<Git: :Base: @logger=nil, @working_directory=#<Git: :WorkingDirectory: @path=" ">, @repository=#<Git: :Repository: @path=" /.git">, @index=#<Git: :Index: @path=" /.git/index">, @lib=#<Git: :Lib: @git_dir=" /.git", @git_index_file=" /.git/index", @git_work_dir=" ", @path=nil, @logger=nil, @git_system_env_variables={
"GIT_DIR"=>nil,
"GIT_WORK_TREE"=>nil,
"GIT_INDEX_FILE"=>nil,
"GIT_SSH"=>nil
}>>, @objectish="", @contents=nil, @trees=nil, @size=nil, @sha="", @tree=#<Git: :Object: :Tree: @base=#<Git: :Base: @logger=nil, @working_directory=#<Git: :WorkingDirectory: @path=" ">, @repository=#<Git: :Repository: @path=" /.git">, @index=#<Git: :Index: @path=" /.git/index">, @lib=#<Git: :Lib: @git_dir=" /.git", @git_index_file=" /.git/index", @git_work_dir=" ", @path=nil, @logger=nil, @git_system_env_variables={
"GIT_DIR"=>nil,
"GIT_WORK_TREE"=>nil,
"GIT_INDEX_FILE"=>nil,
"GIT_SSH"=>nil
}>>, @objectish="", @contents=nil, @trees=nil, @size=nil, @sha=nil, @mode=nil, @blobs=nil>, @parents=[#<Git: :Object: :Commit: @base=#<Git: :Base: @logger=nil, @working_directory=#<Git: :WorkingDirectory: @path=" ">, @repository=#<Git: :Repository: @path=" /.git">, @index=#<Git: :Index: @path=" /.git/index">, @lib=#<Git: :Lib: @git_dir=" /.git", @git_index_file=" /.git/index", @git_work_dir=" ", @path=nil, @logger=nil, @git_system_env_variables={
"GIT_DIR"=>nil,
"GIT_WORK_TREE"=>nil,
"GIT_INDEX_FILE"=>nil,
"GIT_SSH"=>nil
}>>, @objectish="", @contents=nil, @trees=nil, @size=nil, @sha=nil, @tree=nil, @parents=nil, @author=nil, @committer=nil, @message=nil>
], @author=#<Git: :Author: @name=" ", @email="", @date=2022-05-19 23: 02: 18 0000>, @committer=#<Git: :Author: @name=" ", @email=" ", @date=2022-05-19 23: 02: 18 0000>, @message="test: test it">,
:failed=>false
},
{
:commit=>#<Git: :Object: :Commit: @base=#<Git: :Base: @logger=nil, @working_directory=#<Git: :WorkingDirectory: @path=" ">, @repository=#<Git: :Repository: @path=" /.git">, @index=#<Git: :Index: @path=" /.git/index">, @lib=#<Git: :Lib: @git_dir=" /.git", @git_index_file=" /.git/index", @git_work_dir=" ", @path=nil, @logger=nil, @git_system_env_variables={
"GIT_DIR"=>nil,
"GIT_WORK_TREE"=>nil,
"GIT_INDEX_FILE"=>nil,
"GIT_SSH"=>nil
}>>, @objectish="", @contents=nil, @trees=nil, @size=nil, @sha="", @tree=#<Git: :Object: :Tree: @base=#<Git: :Base: @logger=nil, @working_directory=#<Git: :WorkingDirectory: @path=" ">, @repository=#<Git: :Repository: @path=" /.git">, @index=#<Git: :Index: @path=" /.git/index">, @lib=#<Git: :Lib: @git_dir=" /.git", @git_index_file=" /.git/index", @git_work_dir=" ", @path=nil, @logger=nil, @git_system_env_variables={
"GIT_DIR"=>nil,
"GIT_WORK_TREE"=>nil,
"GIT_INDEX_FILE"=>nil,
"GIT_SSH"=>nil
}>>, @objectish="", @contents=nil, @trees=nil, @size=nil, @sha=nil, @mode=nil, @blobs=nil>, @parents=[#<Git: :Object: :Commit: 55ecfdf44940 @base=#<Git: :Base: @logger=nil, @working_directory=#<Git: :WorkingDirectory: @path=" ">, @repository=#<Git: :Repository: @path=" /.git">, @index=#<Git: :Index: @path=" /.git/index">, @lib=#<Git: :Lib: @git_dir=" /.git", @git_index_file=" /.git/index", @git_work_dir=" ", @path=nil, @logger=nil, @git_system_env_variables={
"GIT_DIR"=>nil,
"GIT_WORK_TREE"=>nil,
"GIT_INDEX_FILE"=>nil,
"GIT_SSH"=>nil
}>>, @objectish="", @contents=nil, @trees=nil, @size=nil, @sha=nil, @tree=nil, @parents=nil, @author=nil, @committer=nil, @message=nil>
], @author=#<Git: :Author: @name=" ", @email="", @date=>, @committer=#<Git: :Author: @name="", @email=" ", @date=2022-05-19 23: 01: 37 0000>, @message="Merge remote">,
:failed=>false
}
]
but when I go through the array I can't delete the commit that contains the message "Merge remote".
I am trying this:
a = commits_with_status.delete_if { |x| commits_with_status.include? x["Merge remote"]}
the array is stored in the variable commits_with_status.
But I can't delete the commit that has this message...
CodePudding user response:
May be like this
a = commits_with_status.reject { |commit| commit[:commit].message == "Merge remote" }