Can't add credentials.yml.enc file to VCS - ruby-on-rails

I follow this tutorial to deploy my rails application using capistrano and ruby-mine, one step required to generate encrypted credentials.yml.enc and add it to VCS, but I can't add it using ruby-mine even git add however the file is not present in gitignore file.
You find bellow content of gitignore file, the credentials.yml.enc is part of config directory
>> find . -name ".gitignore" -exec cat {} +
/shelf/
/workspace.xml
/dataSources/
/dataSources.local.xml
/httpRequests/
/sassc
/sass-spec
VERSION
.DS_Store
.sass-cache
*.gem
*.gcno
.svn/*
.cproject
.project
.settings/
*.db
*.aps
GNUmakefile.in
GNUmakefile
/aclocal.m4
/autom4te.cache/
/src/config.h
/config.h.in
/config.log
/config.status
/configure
/libtool
/m4/libtool.m4
/m4/ltoptions.m4
/m4/ltsugar.m4
/m4/ltversion.m4
/m4/lt~obsolete.m4
/script/ar-lib
/script/compile
/script/config.guess
/script/config.sub
/script/depcomp
/script/install-sh
/script/ltmain.sh
/script/missing
/script/test-driver
/src/stamp-h1
/src/Makefile.in
/src/Makefile
libsass/*
*.o
*.lo
*.so
*.dll
*.a
*.suo
*.sdf
*.opendb
*.opensdf
a.out
libsass.js
tester
tester.exe
build/
config.h.in*
lib/pkgconfig/
bin/*
.deps/
.libs/
win/bin
*.user
win/*.db
sassc++
libsass.la
src/support/libsass.pc
sassc/
sass-spec/
installer
.idea
/bin
/.bundle
/db/*.sqlite3
/db/*.sqlite3-journal
/db/*.sqlite3-*
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep
/tmp/pids/*
!/tmp/pids/
!/tmp/pids/.keep
/storage/*
!/storage/.keep
/public/assets
.byebug_history
/config/master.key
/public/packs
/public/packs-test
/node_modules
/yarn-error.log
yarn-debug.log*
.yarn-integrity
>> cat .gitignore
.idea
/bin
/.bundle
/db/*.sqlite3
/db/*.sqlite3-journal
/db/*.sqlite3-*
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep
/tmp/pids/*
!/tmp/pids/
!/tmp/pids/.keep
/storage/*
!/storage/.keep
/public/assets
.byebug_history
/config/master.key
/public/packs
/public/packs-test
/node_modules
/yarn-error.log
yarn-debug.log*
.yarn-integrity
Any help is appreciated, thanks in advance

There is a possibility that the whole folder(and its
subdirectories)/the extension **.enc is excluded in gitignore.
Is the file present when you look at git status. If yes, you'll
need to git add the file before you do a git commit.
Is the file committed already, but not yet pushed?
These are some things on top of my head. Please post some more details to dig this up!

Related

SVN: Add a set of Subdirectories but only specific files

I have a subfolder with a lot of subfolders in it. Each subfolder has an settings.ini file in it. Every once in a while a new subfodler with a Ini-File and a lot of other files and subirectories are added, i want to automatically add and commit it via jenkins, but only the folder and the ini.
C:/Program Files (x86)
-horst
--kevin
---settings.ini
--georg
---settings.ini
--heinz
---settings.ini
--herbert
---settings.ini
...
I tried:
svn.exe --quiet --password %SVNPW% --username "%SVNUSER%" add --depth infinity --parents "C:/Program Files (x86)/horst/*/settings.ini"
But this is not working, I get the message:
svn: E720123: Can't make directory 'C:/Program Files (x86)/horst/*'
Is there another solution, what am I doing wrong
regard Nils
This does the trick
cd "C:/Program Files (x86)/horst"
dir /B /S settings.ini > file_list.txt
%SVN% --quiet --password %SVNPW% --username "%SVNUSER%" add --depth infinity --parents --targets file_list.txt
I created a list of targets I want to add and let SVN crawl it.
Nils

tar: unable to include folder but exclude content

I have a project folder with several directories
- archive
- include
- lib
- src
- src/obj (obj is a subdirectory of src)
I would like tar to pack these directories and their contents into a main.tar, then I will the main.tar into the archive directory.
tar cvz \
--exclude="*.obsolete" --exclude="*DS_Store" --exclude="./archive/*" \
-f main.tar \
./archive ./include ./lib ./src
I would like to exclude the contents of the archive directory but still package the empty directory itself. You can see I am also excluding some other stuff from various places, OSX likes to write .DS_Store files everywhere on my filesystem and I occasionally make copies of files and append .obsolete to the end while working on a new version.
Unfortunately, the empty archive directory is not included in main.tar.
According to this thread, my command should work.
How can the files be excluded from archive but the empty directory be packed into the tar file?
edit
The following fails:
--exclude="./archive/*"
The following works:
--exclude="./archive/*.*"
So the whole command is:
tar cvz \
--exclude="*.obsolete" --exclude="*DS_Store" --exclude="./archive/*.*" \
-f main.tar \
./archive ./include ./lib ./src

.gitignore not ignoring files

Here is my .gitignore file:
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'
# Ignore bundler config.
/.bundle
# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal
# Ignore all logfiles and tempfiles.
/log/*
!/log/.keep
/tmp
# Ignore application configuration
/config/application.yml
/config/application.yml.bak
*.bak
Now, my repository is at https://github.com/rmohan80/learn-rails
Why would my latest commit -- "add configuration for email" add Readme.rdoc.bak but ignore .gitignore.bak
Any clues?
The star character does do match files beginning with a period.
You can add .*.bak to ignore them in your case or you can change the glob option in your shell :
# capture dot file
shopt -s dotglob
# do git stuff here
# stop capturing dot file
shopt -u dotglob
A similar problem solved here : https://stackoverflow.com/a/19365350
You have to checkout the HEAD, so that your repository looks unmodified. Then run the following:
$ echo '*.*.bak' >> .gitignore
To exclude files that are formatted like README.md.bak.
And run
$ echo '**/*.bak' >> .gitignore
to exclude files that are formatted like README.bak anywhere in the tree below the current directory.
Having .bak.bak files is something you don't want.

tar --excludes option to exclude only the directory at current working directory, not subdirectories

I want to tar/zip a directory ./ (current working directory) and exclude files in the directory ./vendor, I happened to also have a subdirectory named vendor at ./public/web/vendor, but I want to keep that. I've tried:
tar cfz /private/var/folders/temp/mage6BRQWJ.tar.gz --exclude=vendor/* ./
tar cfz /private/var/folders/temp/mage6BRQWJ.tar.gz --exclude=./vendor/* ./
tar cfz /private/var/folders/temp/mage6BRQWJ.tar.gz --exclude="vendor/*" ./
But these both exclude the subdirectory.
I want to use relative path because I want to exclude all .svn (e.g. example) files from all directories, too.
Is there a way, using relative path , to exclude files in the ./vendor directory but not ./public/web/vendor ?
All you need is the --anchored tag:
GNU tar:
tar cfz mage6BRQWJ.tar.gz --anchored --exclude=vendor *
bsdtar:
bsdtar -czf mage6BRQWJ-1.tar.gz --exclude=^vendor *
That works.

Rename project in Ruby on Rails 4.0.2

I'm aware of the Rename plugin for rails (https://github.com/get/Rename), but does anyone know of a way to easily rename a project in Rails 4.0.2 seeing as plugins are deprecated beginning with Rails 4?
Just consider you have used
rails new blog
This will create a blog application. Now if you want to rename the folder blog, just use
$mv blog blog_new
This will just rename the folder and the application will run with no issues as external folder name changes will not affect the application. Else you need to change each file as specified by srt32 but i don't see any specific reason to change project name from inside.
Assuming your app name is my_app you can run something like grep -r 'my_app' . from the root of your project and find all the places where the app name is referenced. It shouldn't be that bad to go update them. The list of places should look something like:
config/application.rb
config/environment.rb
config/environments/development.rb
config/environments/test.rb
config/environments/production.rb
config/initializers/secret_token.rb
config/routes.rb
Rakefile
Enter following commands
$ rails new ProjectToRename
$ cd ProjectToRename
$ grep -ri 'project_?to_?rename'
Finally done.
You'll need to rename the top-level directory yourself:
$ cd ..
$ mv ProjectToRename SomeNewName
I've written the following script to do just that. You can see it also at https://gist.github.com/danielpclark/8dfcdd7ac63149323bbc
#!/usr/bin/ruby
# Rename Rails Project (File: rename_rails)
# Copyright 6ft Dan(TM) / MIT License
# Check the config/application.rb for capital usage in project name by model OldProjectName
# Usage: rename_rails OldProjectName NewAwesomeName
# Replace string instances of project name
`grep -lR #{ARGV[0]} | xargs sed -i 's/#{ARGV[0]}/#{ARGV[1]}/g'`
`grep -lR #{ARGV[0].downcase} | xargs sed -i 's/#{ARGV[0].downcase}/#{ARGV[1].downcase}/g'`
# Rename Rails directory if it exists
if File.directory?(ARGV[0])
`mv #{ARGV[0]} #{ARGV[1]}`
drc = ARGV[1]
elsif File.directory?(ARGV[0].downcase)
`mv #{ARGV[0].downcase} #{ARGV[1]}`
drc = ARGV[1]
end
# Delete temporary files (helps prevent errors)
drc ||= ''
if ['cache','pids','sessions','sockets'].all? {
|direc| File.directory?(File.join(drc,'tmp', direc)) }
FileUtils.rm_rf(File.join(drc,'tmp'))
end
And I've created a howto video on YouTube. http://youtu.be/dDw2RmczcDA

Resources