Как использовать решения VCS, такие как SVN или git, для обозначения версии определенных файлов?

313
jake9115

поэтому я начинаю использовать системы контроля версий (VCS) для отслеживания растущих куч кода и экспериментирую с SVN и git. Очень простые команды очень похожи, поэтому я просто буду использовать SVN в качестве примера.

Скажем, у меня есть репозиторий с некоторыми файлами в нем. После изменения файла я фиксирую изменение следующим образом:

svn commit -m "altered the regex to parse properly" 

Это фиксирует мои изменения и добавляет сообщение о коммите. Однако что, если я только что изменил 3 разных скрипта, как я могу добавить индивидуальные сообщения коммита для каждого из файлов?

Точно так же, будучи системой контроля версий, я хочу отслеживать номера версий скриптов. Допустим, я начинаю с версии 1.0.0, как я могу пометить мой измененный скрипт как v1.0.1 при коммите?

В общем, если бы кто-нибудь мог сказать мне, как отслеживать сообщения журнала и изменения версий для каждого файла при фиксации, я был бы очень благодарен. Спасибо!

1

2 ответа на вопрос

5
Horn OK Please

If you want to keep a running change log by file, then you either need to:

  • Create a ChangeLog plain text file in your source tree and type into it whatever info you need (date, time, commit id, summary, etc.) for each file

  • Only commit one file at a time in each commit, this way you will be able to see a commit history in your version control file that lists each file's individual change. This can lead to an inconsistent state of your code though, meaning that if you change two files which depend on one another and only having one file changed leads to an error, you will have broken commits in your code.

VCSes do not typically natively support a per-file commit log while still having commits contain multiple files. You could, however, just put a new line between the description of each file's change in a multi-file commit. Something like this:

Summary: Various bug fixes and updates for Flummox 1.5.2. file1.c: Updated Flummox API for Flummox 1.5.2. file2.c: Fix a string formatting buffer overflow. file3.c: Use new Flummox Advanced Regex engine. 

Most people commit each logically isolated change in a commit, regardless of whether it affects 1 file or 1000.

2
Zoredache

@allquixotic missed the second part about your question which was about version numbers so here is a answer to that part.

how can I label my changed script as being v1.0.1 upon commit

You don't really label your script as being v.1.0.1, you would probably setup a tag for that commit with the v.1.0.1 label.

In git this could be as simple as something like git tag v1.0.1 <commithash>. Tags in SVN are a bit different, since you use the svn copy feature Doc.