Adding text files to a commit

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Adding text files to a commit

AndrewBlack
I have some text files that I would like to include in every commit (if they have changed since the prior commit).  What is the right way to make this happen automatically?  Or else I forget to add them ...

Adding the files to a _separate_ commit breaks Iceberg, because it decides that the image is behind the repo, but there is no code that it can load to bring it up to date.  I’m hoping that if the text files go in the same commit, all will be well.

I’ve made some progress with this.  I have found that if I have staged the text files before I do the commit with Iceberg, then they will be included in the commit.  So what I need is a way of detecting modifications in the local repository (the equivalent of "git status") and then doing a "git add ..." for the changed files.  And then, ideally, hooking this into Iceberg.  Alternatively, I could I suppose write a pre-commit hook as a shell script and just put it in the .git/hooks directory.
Reply | Threaded
Open this post in threaded view
|

Re: Adding text files to a commit

Peter Uhnak
I'm using the following

| repo |
repo := IceRepository registry detect: [ :each | each name = 'my-repo' ].
repo addFilesToIndex: {'CHANGELOG.md'}.

so then the iceberg commit will also include the (external) file change

Peter

On Tue, Feb 27, 2018 at 11:06 PM, Andrew P. Black <[hidden email]> wrote:
I have some text files that I would like to include in every commit (if they have changed since the prior commit).  What is the right way to make this happen automatically?  Or else I forget to add them ...

Adding the files to a _separate_ commit breaks Iceberg, because it decides that the image is behind the repo, but there is no code that it can load to bring it up to date.  I’m hoping that if the text files go in the same commit, all will be well.

I’ve made some progress with this.  I have found that if I have staged the text files before I do the commit with Iceberg, then they will be included in the commit.  So what I need is a way of detecting modifications in the local repository (the equivalent of "git status") and then doing a "git add ..." for the changed files.  And then, ideally, hooking this into Iceberg.  Alternatively, I could I suppose write a pre-commit hook as a shell script and just put it in the .git/hooks directory.

Reply | Threaded
Open this post in threaded view
|

Re: Adding text files to a commit

AndrewBlack

> On 28 Feb 2018, at 12:32 , Peter Uhnák <[hidden email]> wrote:
>
> I'm using the following
>
> | repo |
> repo := IceRepository registry detect: [ :each | each name = 'my-repo' ].
> repo addFilesToIndex: {'CHANGELOG.md'}.
>
> so then the iceberg commit will also include the (external) file change
>

Thank you!  And it turns out that if the file is unchanged, then adding it to the index has no effect, so I can skip that step.

Have you hooked the above code into Iceberg, or do you run it manually?

        Andrew



Reply | Threaded
Open this post in threaded view
|

Re: Adding text files to a commit

Peter Uhnak
And it turns out that if the file is unchanged, then adding it to the index has no effect, so I can skip that step.
this is equivalent to "git add"; further git can only track changes... so adding a file that hasn't changed produces an empty diff

I have it on a class-side in a script method... which also embeds the content of the changelog into the image (compiles into the method)...

But the menus of iceberg are easily extensible (don't remember what exactly you need to subclass)... so you could add a context-menu on a repository with "add file to index" which would open a file dialog.

Peter

On Wed, Feb 28, 2018 at 1:24 AM, Andrew P. Black <[hidden email]> wrote:

> On 28 Feb 2018, at 12:32 , Peter Uhnák <[hidden email]> wrote:
>
> I'm using the following
>
> | repo |
> repo := IceRepository registry detect: [ :each | each name = 'my-repo' ].
> repo addFilesToIndex: {'CHANGELOG.md'}.
>
> so then the iceberg commit will also include the (external) file change
>

Thank you!  And it turns out that if the file is unchanged, then adding it to the index has no effect, so I can skip that step.

Have you hooked the above code into Iceberg, or do you run it manually?

        Andrew