4

本番環境で非常に重要なファイルを持つSVNリポジトリについて考えてみます。

.
├── Makefile
├── README
├── config
│   └── system_configurations
│       └── IMPORTANT.conf
....

開発者IMPORTANT.confはテスト目的でローカルに変更することがよくありますが、誤ってコミットしたくはありません。

このファイルを保護して、コミットすると何らかの警告が表示されたり、特別なコマンドライン引数が必要になったりする方法はありますか?

いくつかのアーキテクチャソリューションがあることを知っています(たとえば、LOCAL_IMPORTANT.confローカルでの使用、シンボリックリンクなど)-SVNレルムからのソリューションを探しています。

4

5 に答える 5

3

たぶんSVNロックメカニズムを使用しますか?

http://tortoisesvn.net/docs/nightly/TortoiseSVN_en/tsvn-dug-locking.html

他のユーザーからロックを「盗む」ことができるため、これは十分な保護を提供しないかもしれませんが、ロックを盗むまで、ユーザーが特定のファイルへの変更をコミットすることを防ぎます。

于 2012-04-29T08:10:26.627 に答える
1

IMPORTANT.confをSVNから完全に除外し、CIサーバーに承認されたものを別の場所(IMPORTANT_Dev.conf、IMPORTANT_Prod.confなど)からコピーさせる方法を見つけました。

技術的には、IMPORTANT.confのコミットの詳細を解析し、開発者を平手打ちするかコミットに失敗するコミット後フックまたはコミット前フックを実行できますが、構成管理にソース管理ツールを使用するのはやり過ぎのようです。

于 2012-04-29T07:57:36.783 に答える
1

おそらくそれは最も単純な解決策ではありませんが、完全に構成可能で一般的です。

svn フック (この場合は pre-commit フック)
さまざまなスクリプト言語を自由に使用でき、次のような事前定義されたコミット コメントで誤って変更されるのを防ぐことができます:
(疑似コード)

if(affected(important_file) && !commmentContains("IMPORTANT_FILE_CHANGE")) {
   return false;
}

Google で多くの記事を見つけることができますが、ここに例を示します:
http://wordaligned.org/articles/a-subversion-pre-commit-hook

于 2012-04-29T08:07:40.717 に答える
1

考えられる解決策はたくさんあります。私はロックを好みます(Khoiが述べたように)。重要なファイルに svn:needs-lock を設定し、実際に変更が必要なまれなケースで明示的にロックできるようにします。

http://svnbook.red-bean.com/en/1.7/svn.advanced.locking.html

別の解決策は、SVN アクセス制御によるものかもしれません。SVN リポジトリにはどのようにアクセスしますか? http アクセスと svn アクセスの両方で、パスにアクセス許可を設定できます。

http://svnbook.red-bean.com/en/1.7/svn.serverconfig.pathbasedauthz.html

于 2012-04-29T08:47:02.343 に答える
0

無視してみてください

# ---------------------------------------------------------------------
#      Ignore all the .txt files in the /trunk/Blah/ directory
# ---------------------------------------------------------------------

# Go to the directory
cd trunk/Blah/              # The directory with the files

# Start editing the properties for the current directory
svn propedit svn:ignore .   # Opens an editor (SVN_EDITOR, EDITOR)

# Add the following value with a new line, save, and exit:
*.txt

# See that things worked
svn propget svn:ignore .    # So you can see the properties
svn status --no-ignore      # You should see an 'I' next to the ignored files

# Commit
svn commit -m "New Ignores" # You must commit the new property change


# ---------------------------------------------------------------------
#     Ignore a single file secret.txt in the /trunk/ directory
# ---------------------------------------------------------------------

# Go to the directory
cd trunk/

# Add just the single file to the current directories ignore list (like above)
# Note the dot at the end of the command is important
svn propset svn:ignore secret.txt .

# See that things worked
svn propget svn:ignore .    # Notice the single file was added to the list
svn status --no-ignore      # You should see an 'I' next to the ignored files

# Commit
svn commit -m "Its secret"  # You must commit the new property change

コミットしたいときは、

svn changelist ignore-on-commit {file-you-want-to-add}

バージョン管理されていないファイルを見つけたい場合は

svn status | grep ^\? | awk '{print $2}'
于 2012-05-01T22:16:45.110 に答える