I am developing an application for issue tracking in which I want to provide the ability to view revision information related to an issue. So, I need to search the git repository for commit with messages containing the issue key.
Currently, the only gem I found that could help me is rugged but it doesn't provide this functionality. You can search only by the sha1.
Any ideas?
my idea would be to just embrace the powers of your command line.
it's super easy to do this in ruby and the git executable plays nice with calling into it:
`git log --oneline --grep=fail`.split("\n")
=> ["a9c6cf1 allow dashes in github names and show errors on failed validations, closes #54", "e140ed6 update friendly_id and fix failing spec", "871b06a remove failing test", "eff0c4b simplify failing test", "f72889f add production env, otherwise asset task will fail, wtf...", "daee196 first step of migrating to rails 3.1"]
this example searches for fail in the commit messages
Related
I've tried a bunch of different things as per suggestions, but cannot get it to work for me, what are some more alternatives?
When I git push, it says its already updated... is it a problem with uploading gem files, css? How can I know where it starts so I can then find an answer. It hasn't recorded any of my git push heroku master commands for a while apparently because there are many things missing & I just found out... Help!!!!
I'm pretty new at this, sorry guys!
You've got to run this from the command line:
git add . # Adds all files into the git
git commit -a -m "Your commit" # Creates commit
git push heroku master # Pushes commit to Heroku
This will put your latest version of code onto Heroku, and then you've got to ensure you've got the database connectivity sorted (so your data updates persist in production)
The problem was in passing a non-matching command to set my amazon bucket to what was on my production environment. Tutorial & huroku development center differed in syntax so I mixed them up apparently. So nothing after image uploading stage would work, all fixed now though! Thx
Assume that I have a Rails project. I have published it on a server like Heroku. Think of it as a small app that have to update a git repository (a separate repository in its public folder). Is there a way to achieve this?
For example...
Think that i have some markdown files in my public folder. My rails app will give me an interface to edit these files. When the editing is over, I need to push these files to a git repository. Only that folder through a script in the Rails app.
You can either shell out to git:
Dir.chdir('/path/to/git/tree') do
system = "git commit -m'Updated by rails' -- #{name_of_file_to_commit}"
# Check $?, and do some appropriate error handling if it's != 0
end
Or you can use one of the several ruby Gems for interfacing with git. I am not familiar enough with them to recommend one; in any case, any recommendation will soon be out of date. It's best to do your own search, find candidate gems, and try them.
My site is currently dead therefore I can't explain how urgent for me this is.
Situation: A few days ago I received an e-mail from Heroku "ACTION REQUIRED: Rails Security Vulnerability " advising me to update rails to version '3.2.11'. After I followed all the steps in the e-mail I tried to open my web site. I was extremely surprised when I saw that I can't open my site. My site is made with RefineryCMS.
Is it possible, using git, to restore my site to the previous point in time when everything was working great?
When I run the site locally I get the following error:
ActiveRecord::RecordNotFound in Refinery::PagesController#home
Couldn't find Refinery::Page with id=torte-za-rodendan
...
app/views/stranice/naslovnica/_favourite_products.html.erb:7:in `_app_views_stranice_naslovnica__favourite_products_html_erb__4156700835010289094_66485000'
app/views/refinery/pages/home.html.erb:16:in `_app_views_refinery_pages_home_html_erb___2482419061129865361_67
Yep, we all got that email from Heroku.
Since your site was versioned with git before, you can undo the last commit by following these steps.
However, I am not sure whether you really need to do the above. You just need to make sure that your heroku app runs on rails 3.2.11 - it is a pretty serious security issue, maybe heroku even blocks sites that aren't upgraded quickly enough.
Follow these steps:
Run your tests and make sure everything works
Open up a new branch through git (git checkout -b new_rails)
Change Rails 3.2.11 in your Gemfile
Change RAILS_GEM_VERSION to '3.2.11' in environment.rb
Run bundle update rails
Run the tests and see if everything still works
If not, reverse back to the old branch by doing git checkout master; optionally delete the new branch by doing git branch -D new_rails
Doing it only on the new branch ensures nothing breaks.
If you still get errors afterwards, please tell us what's in heroku's log.
Being human, it looks like I know so little event about the tools I use every days.
I found a bug in rails, discovered it was already patched, and it dosent seems to be in the versions I currently require (3.2.3).
Here it is :
https://github.com/rails/rails/pull/5168
How would I know if a commit on master would have been packaged into a gem?
If the project has good tags (and rails does), you can use name-rev "which will give the commit a name based on any tag it finds pointing to one of the commit’s descendants" (from http://schacon.github.com/git/user-manual.html#finding-tagged-descendants)
For example, the commit you are looking for is 404b73bce1f9347ca05b1496db8fc64438d66bd2, so you can try:
$ git name-rev --tags 404b73bce1f9347ca05b1496db8fc64438d66bd2
404b73bce1f9347ca05b1496db8fc64438d66bd2 undefined
This tells me that (at the time of this writing) there is no tag that includes 404b73bce1f9347ca05b1496db8fc64438d66bd2, and I'll assume that if it's not tagged, then it hasn't been released.
However, for another example, if I use a commit that I do know is in a release, it shows that it is under the v3.2.3 tag:
$ git name-rev --tags 45d6cd94b3ef2ec77166def41f29188445b35608
45d6cd94b3ef2ec77166def41f29188445b35608 tags/v3.2.3^0
For more ways to find if a commit has been released, check out http://schacon.github.com/git/user-manual.html#finding-tagged-descendants.
I don't think there's any one way to tell. You can take a look at the tags for the project, and that will tell you when new versions of rails are released. Each tag is for a specific commit. If that commit happened after the patch was merged, then the patch is most likely in that version of rails.
You could also view the source of the latest gem file and see if the patch is in there:
gem install rails
gem unpack rails
cd rails-[VERSION]
In bundler you can define a gem that is not yet released, but lives on any git repo, e.g.
gem 'hadoop-csv', :git => 'git://github.com/apohllo/hadoop-csv.git'
You can also specify a branch, tag or even a commit. So this works very well in such circumstances.
Let's say I have a Rails application deployed on Heroku. How can I display these pieces of information in my views?
The Git hash for the last revision
The Timestamp for the last revision
Heroku sets an environment variable with the commit hash ENV['COMMIT_HASH'].
As for the timestamp, you could hit the github api with the hash if you host your code there. Looks like the ruby-github gem can help you with this, or you could do it yourself with HTTParty.
The reason for this is because when your app is deployed onto the dyno grid to serve requests, it's compiled into a "slug" for fast deployment, and this slug doesn't have the git repo with it anymore.
Another way to do it is to deploy with a rake task that gets the version info you want from the local repo and updates an environment variable on the Heroku side. Then you can use a tag, or a commit hash, or anything else, without having to rely on behaviors on the Heroku side.
For example, if you wanted to use the latest tag, in your rake task:
def app_version
%x[git describe --tags --abbrev=0].strip
end
Then in the body of your task:
run "git push blah:blah blah"
run "heroku config:add APP_VERSION=#{app_version}"
I would like to be able to get that info straight from git on Heroku, rather than sneaking it in indirectly, but I've never been able to figure out how to do that.
There is grit installed on Heroku. So you can open the repository there using it.
repo = Repo.new(Rails.root + '.git')
last_commit = repo.commits.first
p last_commit.id
p last_commit.authored_date
I think you need to config.gem 'grit' into your Rails app in order to be able to create the Repo object.
You can read about grit here http://github.com/mojombo/grit/