Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using BitBucket for VFP project
Message
From
12/01/2017 13:52:42
 
 
To
12/01/2017 13:34:26
General information
Forum:
Atlassian
Category:
BitBucket
Miscellaneous
Thread ID:
01646607
Message ID:
01646612
Views:
28
>Perhaps I used the wrong interface, I went on the Cloud interface and then I have to use the command line to stage and push the files.

We are using a local environment. But, I believe this goes in the same way.

As far as the tutorials go, I have went through some of them. But, all that targets as those who want to do repetitive tasks. As for me, I do not have time to do repetitive things over and over again. So, basically, I automated everything and the tutorials only served to give me a head start.

Note also that GIT offers support to integrate itself over certain environments such as .NET. You probably does not have support for VFP. But, that does not change anything. In Visual Studio, it plugged itself into the environment and I didn't really want to have it in there. So, I went into the settings and disable those plugins.

Here is a set of commands I use to push things from local to server. This assumes I have an interface where I have a Status button. When I click on it, it gives me all files which have been changed (new ones, updated ones and deleted ones). I simply cut & paste that into the Files field. Then, I enter my JIRA item(s) related to the deployment in another field. Then, in the Tag(s) field, I enter v2.1, for example, which follows where I am in the BitBucket last deployment version value. The code you see here uses some framework classes to do a few things. But, that should give you an idea at how you can automate things up to BitBucket.

Code for the Status button:
	Private Sub Button129_Click(sender As Object, e As EventArgs) Handles Button129.Click
		Dim lcDirectory As String = ""
		Dim loProcessFile As Framework.ProcessFile = New Framework.ProcessFile(oApp)

        ' Based on the selection
        Select Case GitProject.Text

			' Universal Thread Web site
			Case "Universal Thread Web site"
				lcDirectory = "d:\iis\Universal Thread"

		End Select

		' Initialization
		GitCommand.Text = ""

		' Framework
		loProcessFile.cWorkingDirectory = lcDirectory
		loProcessFile.cFileName = "C:\Program Files\Git\cmd\git.exe"
		loProcessFile.cArguments = "status"
		loProcessFile.lWaitForExit = True
		If Not loProcessFile.Process() Then
			MessageBox.Show(loProcessFile.cMessage)
			Exit Sub
		End If

		' Initialization
		GitCommand.Text = GitCommand.Text + "git status" + oApp.cCR

		' If we have an output
		If loProcessFile.cOutput.Length > 0 Then

			' Initialization
			GitCommand.Text = GitCommand.Text + oApp.cCR
			GitCommand.Text = GitCommand.Text + loProcessFile.cOutput + oApp.cCR

		End If

		' If we have an error
		If loProcessFile.cError.Length > 0 Then

			' Initialization
			GitCommand.Text = GitCommand.Text + oApp.cCR
			GitCommand.Text = GitCommand.Text + loProcessFile.cError + oApp.cCR

		End If

	End Sub
Code for the Commit button:
	Private Sub Button136_Click(sender As Object, e As EventArgs) Handles Button136.Click
		Dim lcDirectory As String = ""
		Dim lcFile As String = ""
		Dim lcMessage As String = ""
		Dim lcSHA As String = ""
		Dim lcTag As String = ""
		Dim lnCounter As Integer = 0
		Dim lnLocation As Integer = 0
		Dim loProcessFile As Framework.ProcessFile = New Framework.ProcessFile(oApp)
		Dim loStringBuilderFile As Framework.StringBuilderFile = New Framework.StringBuilderFile(oApp)

		' Initialization
		GitCommand.Text = ""

		' If we do not have any file
		If GitFile.Text.Length = 0 Then
			MessageBox.Show("You need to enter a file.", cWindowCaption, MessageBoxButtons.OK, MessageBoxIcon.Stop)
			Exit Sub
		End If

		' If we do not have any message
		If GitMessage.Text.Length = 0 Then
			MessageBox.Show("You need to enter a message.", cWindowCaption, MessageBoxButtons.OK, MessageBoxIcon.Stop)
			Exit Sub
		End If

		' If we have some tags
		If GitTag.Text.Length > 0 Then

			' Initialization
			lcTag = GitTag.Text

			' Initialization
			lnLocation = oApp.At(" ", lcTag)

			' If we have a space
			If lnLocation > 0 Then
				MessageBox.Show("You cannot have a space in a tag.", cWindowCaption, MessageBoxButtons.OK, MessageBoxIcon.Stop)
				Exit Sub
			End If

			' Initialization
			lnLocation = oApp.At("'", lcTag)

			' If we have a space
			If lnLocation > 0 Then
				MessageBox.Show("You cannot have a quote in a tag.", cWindowCaption, MessageBoxButtons.OK, MessageBoxIcon.Stop)
				Exit Sub
			End If

		End If

		' Based on the selection
		Select Case GitProject.Text

            ' Command Center
            Case "Command Center"

			' Universal Thread Web site
			Case "Universal Thread Web site"
				lcDirectory = "d:\iis\Universal Thread"

		End Select

		' Initialization
		lcFile = GitFile.Text

		' Remove carriage returns
		lcFile = oApp.NoCr(lcFile)

		' Load the files into the string builder
		loStringBuilderFile.LoadString(lcFile)

		' For each file
		For lnCounter = 1 To loStringBuilderFile.nLine

			' Get the line
			If Not loStringBuilderFile.MLine(lnCounter) Then
				Exit Sub
			End If

			lcFile = """" + loStringBuilderFile.cLine + """"

			' Framework
			loProcessFile.cWorkingDirectory = lcDirectory
			loProcessFile.cFileName = "C:\Program Files\Git\cmd\git.exe"
			loProcessFile.cArguments = "add " + lcFile
			loProcessFile.lWaitForExit = True
			If Not loProcessFile.Process() Then
				MessageBox.Show(loProcessFile.cMessage)
				Exit Sub
			End If

			' If we have a command
			If GitCommand.Text.Length > 0 Then
				GitCommand.Text = GitCommand.Text + oApp.cCR
			End If

			' Initialization
			GitCommand.Text = GitCommand.Text + "git add " + lcFile + oApp.cCR

			' If we have an output
			If loProcessFile.cOutput.Length > 0 Then

				' Initialization
				GitCommand.Text = GitCommand.Text + oApp.cCR
				GitCommand.Text = GitCommand.Text + loProcessFile.cOutput + oApp.cCR

			End If

			' If we have an error
			If loProcessFile.cError.Length > 0 Then

				' Initialization
				GitCommand.Text = GitCommand.Text + oApp.cCR
				GitCommand.Text = GitCommand.Text + loProcessFile.cError + oApp.cCR

			End If

		Next

		' Load the files into the string builder
		loStringBuilderFile.LoadString(GitMessage.Text)

		' For each message
		For lnCounter = 1 To loStringBuilderFile.nLine

			' Get the line
			If Not loStringBuilderFile.MLine(lnCounter) Then
				Exit Sub
			End If

			' If we have a message
			If lcMessage.Length > 0 Then

				' Initialization
				lcMessage = lcMessage + " "

			End If

			lcMessage = lcMessage + "-m """ + loStringBuilderFile.cLine + """"
		Next

		' Framework
		loProcessFile.cWorkingDirectory = lcDirectory
		loProcessFile.cFileName = "C:\Program Files\Git\cmd\git.exe"
		loProcessFile.cArguments = "commit " + lcMessage
		loProcessFile.lWaitForExit = True
		If Not loProcessFile.Process() Then
			MessageBox.Show(loProcessFile.cMessage)
			Exit Sub
		End If

		' Initialization
		GitCommand.Text = GitCommand.Text + oApp.cCR
		GitCommand.Text = GitCommand.Text + "git commit " + lcMessage + oApp.cCR

		' If we have an output
		If loProcessFile.cOutput.Length > 0 Then

			' Initialization
			GitCommand.Text = GitCommand.Text + oApp.cCR
			GitCommand.Text = GitCommand.Text + loProcessFile.cOutput + oApp.cCR

		End If

		' If we have an error
		If loProcessFile.cError.Length > 0 Then

			' Initialization
			GitCommand.Text = GitCommand.Text + oApp.cCR
			GitCommand.Text = GitCommand.Text + loProcessFile.cError + oApp.cCR

		End If

		' Initialization
		GitCommand.Text = GitCommand.Text + oApp.cCR
		GitCommand.Text = GitCommand.Text + "git push -u origin master" + oApp.cCR

		' Framework
		loProcessFile.cWorkingDirectory = lcDirectory
		loProcessFile.cFileName = "C:\Program Files\Git\cmd\git.exe"
		loProcessFile.cArguments = "push -u origin master"
		loProcessFile.lWaitForExit = True
		If Not loProcessFile.Process() Then
			MessageBox.Show(loProcessFile.cMessage)
			Exit Sub
		End If

		' If we have an output
		If loProcessFile.cOutput.Length > 0 Then

			' Initialization
			GitCommand.Text = GitCommand.Text + oApp.cCR
			GitCommand.Text = GitCommand.Text + loProcessFile.cOutput + oApp.cCR

		End If

		' If we have an error
		If loProcessFile.cError.Length > 0 Then

			' Initialization
			GitCommand.Text = GitCommand.Text + oApp.cCR
			GitCommand.Text = GitCommand.Text + loProcessFile.cError + oApp.cCR

		End If

		' If we have some tags
		If GitTag.Text.Length > 0 Then

			' If we have a command
			If GitCommand.Text.Length > 0 Then
				GitCommand.Text = GitCommand.Text + oApp.cCR
			End If

			' Initialization
			GitCommand.Text = GitCommand.Text + "git rev-parse HEAD" + oApp.cCR

			' Load the tags into the string builder
			loStringBuilderFile.LoadString(GitTag.Text)

			' Framework
			loProcessFile.cWorkingDirectory = lcDirectory
			loProcessFile.cFileName = "C:\Program Files\Git\cmd\git.exe"
			loProcessFile.cArguments = "rev-parse HEAD"
			loProcessFile.lWaitForExit = True
			If Not loProcessFile.Process() Then
				MessageBox.Show(loProcessFile.cMessage)
				Exit Sub
			End If

			' If we have an output
			If loProcessFile.cOutput.Length > 0 Then

				' Initialization
				GitCommand.Text = GitCommand.Text + oApp.cCR
				GitCommand.Text = GitCommand.Text + loProcessFile.cOutput + oApp.cCR

			End If

			' If we have an error
			If loProcessFile.cError.Length > 0 Then

				' Initialization
				GitCommand.Text = GitCommand.Text + oApp.cCR
				GitCommand.Text = GitCommand.Text + loProcessFile.cError + oApp.cCR

			End If

			' Initialization
			lcSHA = loProcessFile.cOutput

			' Just take the first seven characters
			lcSHA = Mid(lcSHA, 1, 7)

			' For each tag
			For lnCounter = 1 To loStringBuilderFile.nLine

				' Get the line
				If Not loStringBuilderFile.MLine(lnCounter) Then
					Exit Sub
				End If

				lcTag = loStringBuilderFile.cLine

				' Initialization
				lcTag = Trim(lcTag)

				' If we have a tag
				If lcTag.Length > 0 Then

					' If we have a command
					If GitCommand.Text.Length > 0 Then
						GitCommand.Text = GitCommand.Text + oApp.cCR
					End If

					' Initialization
					GitCommand.Text = GitCommand.Text + "git tag " + lcTag + " " + lcSHA + oApp.cCR

					' Framework
					loProcessFile.cWorkingDirectory = lcDirectory
					loProcessFile.cFileName = "C:\Program Files\Git\cmd\git.exe"
					loProcessFile.cArguments = "tag " + lcTag + " " + lcSHA
					loProcessFile.lWaitForExit = True
					If Not loProcessFile.Process() Then
						MessageBox.Show(loProcessFile.cMessage)
						Exit Sub
					End If

					' If we have an output
					If loProcessFile.cOutput.Length > 0 Then

						' Initialization
						GitCommand.Text = GitCommand.Text + oApp.cCR
						GitCommand.Text = GitCommand.Text + loProcessFile.cOutput + oApp.cCR

					End If

					' If we have an error
					If loProcessFile.cError.Length > 0 Then

						' Initialization
						GitCommand.Text = GitCommand.Text + oApp.cCR
						GitCommand.Text = GitCommand.Text + loProcessFile.cError + oApp.cCR

					End If

				End If

			Next

			' Initialization
			GitCommand.Text = GitCommand.Text + oApp.cCR
			GitCommand.Text = GitCommand.Text + "git push --tags origin master" + oApp.cCR

			' Framework
			loProcessFile.cWorkingDirectory = lcDirectory
			loProcessFile.cFileName = "C:\Program Files\Git\cmd\git.exe"
			loProcessFile.cArguments = "push --tags origin master"
			loProcessFile.lWaitForExit = True
			If Not loProcessFile.Process() Then
				MessageBox.Show(loProcessFile.cMessage)
				Exit Sub
			End If

			' If we have an output
			If loProcessFile.cOutput.Length > 0 Then

				' Initialization
				GitCommand.Text = GitCommand.Text + oApp.cCR
				GitCommand.Text = GitCommand.Text + loProcessFile.cOutput + oApp.cCR

			End If

			' If we have an error
			If loProcessFile.cError.Length > 0 Then

				' Initialization
				GitCommand.Text = GitCommand.Text + oApp.cCR
				GitCommand.Text = GitCommand.Text + loProcessFile.cError + oApp.cCR

			End If

		End If

		' Reset the values
		GitFile.Text = ""
		GitMessage.Text = ""
		GitTag.Text = ""

		' Delete a tag locally
		' git tag -d <tag>

		' Delete a tag on the server
		' git push origin :refs/tags/<tag>

	End Sub
The code is in .NET but that is fairly easy to understand.

I also attached an image of my interface.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform