johnmehr / gitup

A minimalist, dependency-free FreeBSD program to clone/pull Git repositories.
BSD 2-Clause "Simplified" License
51 stars 9 forks source link

.gituprevision is not updated when tag is requested #33

Closed michael-o closed 3 years ago

michael-o commented 3 years ago

See:

# /gitup stable > out 2>&1
root@bsd1srv:~/gitup (main %=)
# head out
# Host: github.com
# Port: 443
# Repository: /freebsd/freebsd.git
# Target: /usr/src
# Have: 1d21fe9cea3f530b4cfca495632d5a1595a32270
# Want: 2e0dd1574137757c4267c38c11493aab005136e3
# Branch: refs/heads/stable/12
# Action: pull
 * /usr/src/COPYRIGHT
 * /usr/src/Makefile.inc1
root@bsd1srv:~/gitup (main %=)
# cat /usr/src/.gituprevision
stable/12:2e0dd1574
root@bsd1srv:~/gitup (main %=)
# /gitup stable -t release/12.2.0  -v2 > out 2>&1
root@bsd1srv:~/gitup (main %=)
# grep Branch: out
# Branch: refs/tags/release/12.2.0
root@bsd1srv:~/gitup (main %=)
# cat /usr/src/.gituprevision
stable/12:1d21fe9ce
root@bsd1srv:~/gitup (main %=)
#

I would expect .gituprevision to contain release/12.2.0:1d21fe9ce.

johnmehr commented 3 years ago

Thank you for catching this! I just pushed the fix for it.

michael-o commented 3 years ago

Something is fishy here:

# git log --pretty=oneline | head -1
2d3daf03549374b31c40a068c3e8a9ab71f426f9 Updated fix for Issue #37 plus added an additional error message clarification
root@bsd1srv:~/gitup (main %=)
# make clean
rm -f gitup.1 gitup.conf.5 gitup.full.bc gitup.full.ll gitup gitup.bc gitup.ll gitup.full gitup.debug gitup.o gitup.bco gitup.llo gitup.1.gz gitup.conf.5.gz gitup.1.cat.gz gitup.conf.5.cat.gz
root@bsd1srv:~/gitup (main %=)
# make
Warning: Object directory not changed from original /root/gitup
cc  -O2 -pipe -DCONFIG_FILE_PATH=\"/usr/local/etc/gitup.conf\"   -g -MD  -MF.depend.gitup.o -MTgitup.o -std=gnu99 -Wno-format-zero-length -fstack-protector-strong -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -Wold-style-definition -Wno-pointer-sign -Wmissing-variable-declarations -Wthread-safety -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable  -Qunused-arguments  -c gitup.c -o gitup.o
cc -O2 -pipe -DCONFIG_FILE_PATH=\"/usr/local/etc/gitup.conf\" -g -std=gnu99 -Wno-format-zero-length -fstack-protector-strong -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -Wold-style-definition -Wno-pointer-sign -Wmissing-variable-declarations -Wthread-safety -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Qunused-arguments   -o gitup.full gitup.o  -lssl -lz -lcrypto -lprivateucl
objcopy --only-keep-debug gitup.full gitup.debug
objcopy --strip-debug --add-gnu-debuglink=gitup.debug  gitup.full gitup
sed -e "s,%%CONFIG_FILE_PATH%%,/usr/local/etc/gitup.conf,g"  gitup.1.in > gitup.1
gzip -cn gitup.1 > gitup.1.gz
sed -e "s,%%CONFIG_FILE_PATH%%,/usr/local/etc/gitup.conf,g"  gitup.conf.5.in > gitup.conf.5
gzip -cn gitup.conf.5 > gitup.conf.5.gz
root@bsd1srv:~/gitup (main %=)
# make install
install  -s -o root -g wheel -m 555   gitup /gitup
install  -o root -g wheel -m 444  gitup.debug /.debug/gitup.debug
install  -o root -g wheel -m 444 gitup.1.gz  /usr/share/man/man1/
install  -o root -g wheel -m 444 gitup.conf.5.gz  /usr/share/man/man5/
root@bsd1srv:~/gitup (main %=)
# /gitup stable
# Host: github.com
# Port: 443
# Repository: /freebsd/freebsd.git
# Target: /usr/src
# Have: c735bf1ae3874ce1e9cfa718b95aad628b91f030
# Want: c735bf1ae3874ce1e9cfa718b95aad628b91f030
# Branch: stable/12
root@bsd1srv:~/gitup (main %=)
# cat /usr/src/.gituprevision
stable/12:c735bf1ae
root@bsd1srv:~/gitup (main %=)
# rm /usr/src/.gituprevision
root@bsd1srv:~/gitup (main %=)
# /gitup stable
# Host: github.com
# Port: 443
# Repository: /freebsd/freebsd.git
# Target: /usr/src
# Have: c735bf1ae3874ce1e9cfa718b95aad628b91f030
# Want: c735bf1ae3874ce1e9cfa718b95aad628b91f030
# Branch: stable/12
root@bsd1srv:~/gitup (main %=)
# cat /usr/src/.gituprevision
cat: /usr/src/.gituprevision: No such file or directory

The same applies to -t:

root@bsd1srv:~/gitup (main %=)
# /gitup stable -t release/12.2.0
# Host: github.com
# Port: 443
# Repository: /freebsd/freebsd.git
# Target: /usr/src
# Tag: release/12.2.0
# Have: c735bf1ae3874ce1e9cfa718b95aad628b91f030
# Want: 1d21fe9cea3f530b4cfca495632d5a1595a32270
# Branch: stable/12
# Action: pull
root@bsd1srv:~/gitup (main %=)
# cat /usr/src/.gituprevision
release/12.2.0:1d21fe9ce
root@bsd1srv:~/gitup (main %=)
# rm /usr/src/.gituprevision
root@bsd1srv:~/gitup (main %=)
# /gitup stable -t release/12.2.0
# Host: github.com
# Port: 443
# Repository: /freebsd/freebsd.git
# Target: /usr/src
# Tag: release/12.2.0
# Have: 1d21fe9cea3f530b4cfca495632d5a1595a32270
# Want: 1d21fe9cea3f530b4cfca495632d5a1595a32270
# Branch: stable/12
root@bsd1srv:~/gitup (main %=)
# cat /usr/src/.gituprevision
cat: /usr/src/.gituprevision: No such file or directory

It seems like when have == want the file is not created.

Can you confirm this?

johnmehr commented 3 years ago

I just moved the .gituprevision code to the main procedure so it gets updated on every run where a want or a tag is known. How does it look now?

michael-o commented 3 years ago

Works for me now. Thanks!